From ec2ae41b815c4c465a856d800709de6147e5e54f Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 17 Mar 2023 02:27:53 +0900 Subject: refactor: make Document type class --- nuldoc-src/templates/tag.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'nuldoc-src/templates/tag.ts') diff --git a/nuldoc-src/templates/tag.ts b/nuldoc-src/templates/tag.ts index a53e59d..8c296d8 100644 --- a/nuldoc-src/templates/tag.ts +++ b/nuldoc-src/templates/tag.ts @@ -22,15 +22,15 @@ export default async function convertTag( ): Promise { const tagLabel = (config.blog.tagLabels as { [key: string]: string })[tag]; - const doc = { - root: el("__root__", []), - sourceFilePath: ``, - link: `/tags/${tag}/`, - title: tagLabel, - summary: `タグ「${tagLabel}」のついた記事一覧`, - tags: [], - revisions: [], - }; + const doc = new Document( + el("__root__", []), + ``, + `/tags/${tag}/`, + tagLabel, + `タグ「${tagLabel}」のついた記事一覧`, + [], + [], + ); const headChildren = [ metaElement([["charset", "UTF-8"]]), @@ -42,7 +42,7 @@ export default async function convertTag( metaElement([["name", "copyright"], [ "content", `© ${ - posts[posts.length - 1].revisions[0].date.substring(0, 4) + posts[posts.length - 1].getCreatedDate().substring(0, 4) } ${config.blog.author}`, ]]), metaElement([["name", "description"], [ @@ -117,16 +117,16 @@ export default async function convertTag( text("Posted on"), el( "time", - [["datetime", post.revisions[0].date]], - text(post.revisions[0].date), + [["datetime", post.getCreatedDate()]], + text(post.getCreatedDate()), ), ...(post.revisions.length > 1 ? [ text(", updated on "), el("time", [[ "datetime", - post.revisions[post.revisions.length - 1].date, - ]], text(post.revisions[post.revisions.length - 1].date)), + post.getUpdatedDate(), + ]], text(post.getUpdatedDate())), ] : []), ), -- cgit v1.2.3-70-g09d2