Format inline code blocks in article titles
This commit is contained in:
parent
5f38355d5c
commit
5906655902
8
html.ts
8
html.ts
@ -53,7 +53,7 @@ export async function articleHtml(
|
|||||||
<main>
|
<main>
|
||||||
<header>
|
<header>
|
||||||
${draftLabel}
|
${draftLabel}
|
||||||
<h1>${article.title}</h1>
|
<h1>${titleHtml(article.title)}</h1>
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
<img class="avatar" src="${profile.picture}" alt="User Avatar" />
|
<img class="avatar" src="${profile.picture}" alt="User Avatar" />
|
||||||
<div class="content">
|
<div class="content">
|
||||||
@ -77,12 +77,16 @@ export async function articleHtml(
|
|||||||
return htmlLayout({ title: pageTitle, body, metaHtml });
|
return htmlLayout({ title: pageTitle, body, metaHtml });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function titleHtml(title: string) {
|
||||||
|
return title.replace(/`([^`]+)`/g, "<code>$1</code>");
|
||||||
|
}
|
||||||
|
|
||||||
function articleListItemHtml(article: Article): string {
|
function articleListItemHtml(article: Article): string {
|
||||||
const formattedDate = localizeDate(article.publishedAt);
|
const formattedDate = localizeDate(article.publishedAt);
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<h3><a href="/${article.naddr}">${article.title}</a></h3>
|
<h3><a href="/${article.naddr}">${titleHtml(article.title)}</a></h3>
|
||||||
<p class="meta">
|
<p class="meta">
|
||||||
${formattedDate}
|
${formattedDate}
|
||||||
</p>
|
</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user