diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-08-14 03:08:58 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-08-14 03:08:58 +0900 |
| commit | a8e51a340d18c3b4a89c8ec3349b70f0715cd2f8 (patch) | |
| tree | 99fc7a335718ad63e29d24c7766611f798cd326e /vhosts/blog/nuldoc-src/components/page_layout.ts | |
| parent | 59d83667eda9ecdab05961da81c18f058a8ac065 (diff) | |
| download | nsfisis.dev-a8e51a340d18c3b4a89c8ec3349b70f0715cd2f8.tar.gz nsfisis.dev-a8e51a340d18c3b4a89c8ec3349b70f0715cd2f8.tar.zst nsfisis.dev-a8e51a340d18c3b4a89c8ec3349b70f0715cd2f8.zip | |
refactor(blog/nuldoc): use object value directly instead of key-value pairs to construct attribute pairs
Diffstat (limited to 'vhosts/blog/nuldoc-src/components/page_layout.ts')
| -rw-r--r-- | vhosts/blog/nuldoc-src/components/page_layout.ts | 67 |
1 files changed, 23 insertions, 44 deletions
diff --git a/vhosts/blog/nuldoc-src/components/page_layout.ts b/vhosts/blog/nuldoc-src/components/page_layout.ts index 391305c1..a6b75d01 100644 --- a/vhosts/blog/nuldoc-src/components/page_layout.ts +++ b/vhosts/blog/nuldoc-src/components/page_layout.ts @@ -25,52 +25,31 @@ export async function pageLayout( ): Promise<Element> { const head = el( "head", - [], - metaElement([["charset", "UTF-8"]]), - metaElement([["name", "viewport"], [ - "content", - "width=device-width, initial-scale=1.0", - ]]), - metaElement([["name", "author"], ["content", config.blog.author]]), - metaElement([["name", "copyright"], [ - "content", - `© ${metaCopyrightYear} ${config.blog.author}`, - ]]), - metaElement([["name", "description"], [ - "content", - metaDescription, - ]]), + {}, + metaElement({ charset: "UTF-8" }), + metaElement({ + name: "viewport", + content: "width=device-width, initial-scale=1.0", + }), + metaElement({ name: "author", content: config.blog.author }), + metaElement({ + name: "copyright", + content: `© ${metaCopyrightYear} ${config.blog.author}`, + }), + metaElement({ name: "description", content: metaDescription }), ...(metaKeywords.length === 0 ? [] : [ - metaElement([["name", "keywords"], [ - "content", - metaKeywords.join(","), - ]]), - ]), - metaElement([ - ["property", "og:type"], - ["content", "article"], - ]), - metaElement([ - ["property", "og:title"], - ["content", metaTitle], - ]), - metaElement([ - ["property", "og:description"], - ["content", metaDescription], - ]), - metaElement([ - ["property", "og:site_name"], - ["content", config.blog.siteName], - ]), - metaElement([ - ["property", "og:locale"], - ["content", "ja_JP"], + metaElement({ name: "keywords", content: metaKeywords.join(",") }), ]), + metaElement({ property: "og:type", content: "article" }), + metaElement({ property: "og:title", content: metaTitle }), + metaElement({ property: "og:description", content: metaDescription }), + metaElement({ property: "og:site_name", content: config.blog.siteName }), + metaElement({ property: "og:locale", content: "ja_JP" }), ...(metaAtomFeedHref ? [linkElement("alternate", metaAtomFeedHref, "application/atom+xml")] : []), linkElement("icon", "/favicon.svg", "image/svg+xml"), - el("title", [], metaTitle), + el("title", {}, metaTitle), await stylesheetLinkElement("/style.css", config), ...( requiresSyntaxHighlight @@ -80,13 +59,13 @@ export async function pageLayout( ); return el( "html", - [["lang", "ja-JP"]], + { lang: "ja-JP" }, head, body, ); } -function metaElement(attrs: [string, string][]): Element { +function metaElement(attrs: Record<string, string>): Element { return el("meta", attrs); } @@ -95,9 +74,9 @@ function linkElement( href: string, type: string | null, ): Element { - const attrs: [string, string][] = [["rel", rel], ["href", href]]; + const attrs: Record<string, string> = { rel: rel, href: href }; if (type !== null) { - attrs.push(["type", type]); + attrs.type = type; } return el("link", attrs); } |
