diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-04-20 23:30:01 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-04-20 23:44:30 +0900 |
| commit | b372b90ae4f65855d6f7132c7722f0228f43daa8 (patch) | |
| tree | b674bd7cfbba7922612d2af0c9788ad7f17fd23a /vhosts/blog/nuldoc-src | |
| parent | 12dfd15b801b382722de48e4e198a6d2c09fe491 (diff) | |
| download | nsfisis.dev-b372b90ae4f65855d6f7132c7722f0228f43daa8.tar.gz nsfisis.dev-b372b90ae4f65855d6f7132c7722f0228f43daa8.tar.zst nsfisis.dev-b372b90ae4f65855d6f7132c7722f0228f43daa8.zip | |
feat(blog/nuldoc): support internal (not published) revision
Diffstat (limited to 'vhosts/blog/nuldoc-src')
| -rw-r--r-- | vhosts/blog/nuldoc-src/commands/build.ts | 6 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/components/post_page_entry.ts | 9 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/components/slide_page_entry.ts | 12 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/ndoc/document.ts | 2 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/ndoc/parse.ts | 2 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/about.ts | 8 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/post.ts | 15 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/post_list.ts | 6 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/slide.ts | 6 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/slide_list.ts | 6 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/pages/tag.ts | 4 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/revision.ts | 1 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/slide/parse.ts | 1 | ||||
| -rw-r--r-- | vhosts/blog/nuldoc-src/slide/slide.ts | 6 |
14 files changed, 53 insertions, 31 deletions
diff --git a/vhosts/blog/nuldoc-src/commands/build.ts b/vhosts/blog/nuldoc-src/commands/build.ts index 355604d8..1ad08825 100644 --- a/vhosts/blog/nuldoc-src/commands/build.ts +++ b/vhosts/blog/nuldoc-src/commands/build.ts @@ -12,7 +12,7 @@ import { generateHomePage } from "../pages/home.ts"; import { generateNotFoundPage } from "../pages/not_found.ts"; import { generatePostPage, - getPostCreatedDate, + getPostPublishedDate, PostPage, } from "../pages/post.ts"; import { generatePostListPage } from "../pages/post_list.ts"; @@ -202,8 +202,8 @@ function collectTags(taggedPages: TaggedPage[]): [string, TaggedPage[]][] { result.push([ tag, tagsAndPages.get(tag).sort((a: TaggedPage, b: TaggedPage) => { - const ta = dateToString(getPostCreatedDate(a)); - const tb = dateToString(getPostCreatedDate(b)); + const ta = dateToString(getPostPublishedDate(a)); + const tb = dateToString(getPostPublishedDate(b)); if (ta > tb) return -1; if (ta < tb) return 1; return 0; diff --git a/vhosts/blog/nuldoc-src/components/post_page_entry.ts b/vhosts/blog/nuldoc-src/components/post_page_entry.ts index bed7698a..9a58efb1 100644 --- a/vhosts/blog/nuldoc-src/components/post_page_entry.ts +++ b/vhosts/blog/nuldoc-src/components/post_page_entry.ts @@ -1,7 +1,8 @@ import { el, Element, text } from "../dom.ts"; import { - getPostCreatedDate, + getPostPublishedDate, getPostUpdatedDate, + postHasAnyUpdates, PostPage, } from "../pages/post.ts"; import { dateToString } from "../revision.ts"; @@ -28,11 +29,11 @@ export function postPageEntry(post: PostPage): Element { [["class", "entry-footer"]], el( "time", - [["datetime", dateToString(getPostCreatedDate(post))]], - text(dateToString(getPostCreatedDate(post))), + [["datetime", dateToString(getPostPublishedDate(post))]], + text(dateToString(getPostPublishedDate(post))), ), text(" 投稿"), - ...(post.revisions.length > 1 + ...(postHasAnyUpdates(post) ? [ text("、"), el("time", [[ diff --git a/vhosts/blog/nuldoc-src/components/slide_page_entry.ts b/vhosts/blog/nuldoc-src/components/slide_page_entry.ts index 6d8908b8..bd2d8978 100644 --- a/vhosts/blog/nuldoc-src/components/slide_page_entry.ts +++ b/vhosts/blog/nuldoc-src/components/slide_page_entry.ts @@ -1,5 +1,9 @@ import { el, Element, text } from "../dom.ts"; -import { getPostCreatedDate, getPostUpdatedDate } from "../pages/post.ts"; +import { + getPostPublishedDate, + getPostUpdatedDate, + postHasAnyUpdates, +} from "../pages/post.ts"; import { SlidePage } from "../pages/slide.ts"; import { dateToString } from "../revision.ts"; @@ -25,11 +29,11 @@ export function slidePageEntry(slide: SlidePage): Element { [["class", "entry-footer"]], el( "time", - [["datetime", dateToString(getPostCreatedDate(slide))]], - text(dateToString(getPostCreatedDate(slide))), + [["datetime", dateToString(getPostPublishedDate(slide))]], + text(dateToString(getPostPublishedDate(slide))), ), text(" 登壇"), - ...(slide.revisions.length > 1 + ...(postHasAnyUpdates(slide) ? [ text("、"), el("time", [[ diff --git a/vhosts/blog/nuldoc-src/ndoc/document.ts b/vhosts/blog/nuldoc-src/ndoc/document.ts index cbf0473c..c99fb7f0 100644 --- a/vhosts/blog/nuldoc-src/ndoc/document.ts +++ b/vhosts/blog/nuldoc-src/ndoc/document.ts @@ -26,6 +26,7 @@ export function createNewDocumentFromRootElement( revisions: { date: string; remark: string; + isInternal?: boolean; }[]; }; }, @@ -54,6 +55,7 @@ export function createNewDocumentFromRootElement( number: i, date: stringToDate(r.date), remark: r.remark, + isInternal: !!r.isInternal, })), }; } diff --git a/vhosts/blog/nuldoc-src/ndoc/parse.ts b/vhosts/blog/nuldoc-src/ndoc/parse.ts index 7c33c414..f6f77dbb 100644 --- a/vhosts/blog/nuldoc-src/ndoc/parse.ts +++ b/vhosts/blog/nuldoc-src/ndoc/parse.ts @@ -30,6 +30,7 @@ function parseMetaInfo(s: string): { revisions: { date: string; remark: string; + isInternal?: boolean; }[]; }; } { @@ -42,6 +43,7 @@ function parseMetaInfo(s: string): { revisions: { date: string; remark: string; + isInternal?: boolean; }[]; }; }; diff --git a/vhosts/blog/nuldoc-src/pages/about.ts b/vhosts/blog/nuldoc-src/pages/about.ts index 6ef2e05e..e78c109f 100644 --- a/vhosts/blog/nuldoc-src/pages/about.ts +++ b/vhosts/blog/nuldoc-src/pages/about.ts @@ -6,7 +6,7 @@ import { Config } from "../config.ts"; import { el, text } from "../dom.ts"; import { Page } from "../page.ts"; import { dateToString } from "../revision.ts"; -import { getPostCreatedDate } from "./post.ts"; +import { getPostPublishedDate } from "./post.ts"; import { SlidePage } from "./slide.ts"; export type AboutPage = Page; @@ -134,8 +134,8 @@ export async function generateAboutPage( "ul", [], ...Array.from(slides).sort((a, b) => { - const ta = dateToString(getPostCreatedDate(a)); - const tb = dateToString(getPostCreatedDate(b)); + const ta = dateToString(getPostPublishedDate(a)); + const tb = dateToString(getPostPublishedDate(b)); if (ta > tb) return -1; if (ta < tb) return 1; return 0; @@ -148,7 +148,7 @@ export async function generateAboutPage( [["href", slide.href]], text( `${ - dateToString(getPostCreatedDate(slide)) + dateToString(getPostPublishedDate(slide)) }: ${slide.event} (${slide.talkType})`, ), ), diff --git a/vhosts/blog/nuldoc-src/pages/post.ts b/vhosts/blog/nuldoc-src/pages/post.ts index f7e53421..b5f954ea 100644 --- a/vhosts/blog/nuldoc-src/pages/post.ts +++ b/vhosts/blog/nuldoc-src/pages/post.ts @@ -18,7 +18,12 @@ export interface PostPage extends Page { uuid: string; } -export function getPostCreatedDate(page: { revisions: Revision[] }): Date { +export function getPostPublishedDate(page: { revisions: Revision[] }): Date { + for (const rev of page.revisions) { + if (!rev.isInternal) { + return rev.date; + } + } return page.revisions[0].date; } @@ -26,6 +31,10 @@ export function getPostUpdatedDate(page: { revisions: Revision[] }): Date { return page.revisions[page.revisions.length - 1].date; } +export function postHasAnyUpdates(page: { revisions: Revision[] }): boolean { + return 2 <= page.revisions.filter((rev) => !rev.isInternal).length; +} + export async function generatePostPage( doc: Document, config: Config, @@ -114,7 +123,7 @@ export async function generatePostPage( const html = await pageLayout( { - metaCopyrightYear: getPostCreatedDate(doc).year, + metaCopyrightYear: getPostPublishedDate(doc).year, metaDescription: doc.description, metaKeywords: doc.tags.map((slug) => getTagLabel(config, slug)), metaTitle: `${doc.title}|${config.blog.siteName}`, @@ -139,7 +148,7 @@ export async function generatePostPage( description: doc.description, tags: doc.tags, revisions: doc.revisions, - published: getPostCreatedDate(doc), + published: getPostPublishedDate(doc), updated: getPostUpdatedDate(doc), uuid: doc.uuid, }; diff --git a/vhosts/blog/nuldoc-src/pages/post_list.ts b/vhosts/blog/nuldoc-src/pages/post_list.ts index 7cee87e7..111ecd62 100644 --- a/vhosts/blog/nuldoc-src/pages/post_list.ts +++ b/vhosts/blog/nuldoc-src/pages/post_list.ts @@ -6,7 +6,7 @@ import { Config } from "../config.ts"; import { el, text } from "../dom.ts"; import { Page } from "../page.ts"; import { dateToString } from "../revision.ts"; -import { getPostCreatedDate, PostPage } from "./post.ts"; +import { getPostPublishedDate, PostPage } from "./post.ts"; export type PostListPage = Page; @@ -33,8 +33,8 @@ export async function generatePostListPage( ), ), ...Array.from(posts).sort((a, b) => { - const ta = dateToString(getPostCreatedDate(a)); - const tb = dateToString(getPostCreatedDate(b)); + const ta = dateToString(getPostPublishedDate(a)); + const tb = dateToString(getPostPublishedDate(b)); if (ta > tb) return -1; if (ta < tb) return 1; return 0; diff --git a/vhosts/blog/nuldoc-src/pages/slide.ts b/vhosts/blog/nuldoc-src/pages/slide.ts index 5e4d1834..88069708 100644 --- a/vhosts/blog/nuldoc-src/pages/slide.ts +++ b/vhosts/blog/nuldoc-src/pages/slide.ts @@ -8,7 +8,7 @@ import { el, text } from "../dom.ts"; import { Page } from "../page.ts"; import { Date, dateToString, Revision } from "../revision.ts"; import { Slide } from "../slide/slide.ts"; -import { getPostCreatedDate, getPostUpdatedDate } from "./post.ts"; +import { getPostPublishedDate, getPostUpdatedDate } from "./post.ts"; export interface SlidePage extends Page { title: string; @@ -113,7 +113,7 @@ export async function generateSlidePage( const html = await pageLayout( { - metaCopyrightYear: getPostCreatedDate(slide).year, + metaCopyrightYear: getPostPublishedDate(slide).year, metaDescription: slide.title, metaKeywords: slide.tags.map((slug) => getTagLabel(config, slug)), metaTitle: `${slide.event} (${slide.talkType})|${config.blog.siteName}`, @@ -141,7 +141,7 @@ export async function generateSlidePage( slideLink: slide.slideLink, tags: slide.tags, revisions: slide.revisions, - published: getPostCreatedDate(slide), + published: getPostPublishedDate(slide), updated: getPostUpdatedDate(slide), uuid: slide.uuid, }; diff --git a/vhosts/blog/nuldoc-src/pages/slide_list.ts b/vhosts/blog/nuldoc-src/pages/slide_list.ts index 0b59b1dc..738f42ac 100644 --- a/vhosts/blog/nuldoc-src/pages/slide_list.ts +++ b/vhosts/blog/nuldoc-src/pages/slide_list.ts @@ -6,7 +6,7 @@ import { Config } from "../config.ts"; import { el, text } from "../dom.ts"; import { Page } from "../page.ts"; import { dateToString } from "../revision.ts"; -import { getPostCreatedDate } from "./post.ts"; +import { getPostPublishedDate } from "./post.ts"; import { SlidePage } from "./slide.ts"; export type SlideListPage = Page; @@ -34,8 +34,8 @@ export async function generateSlideListPage( ), ), ...Array.from(slides).sort((a, b) => { - const ta = dateToString(getPostCreatedDate(a)); - const tb = dateToString(getPostCreatedDate(b)); + const ta = dateToString(getPostPublishedDate(a)); + const tb = dateToString(getPostPublishedDate(b)); if (ta > tb) return -1; if (ta < tb) return 1; return 0; diff --git a/vhosts/blog/nuldoc-src/pages/tag.ts b/vhosts/blog/nuldoc-src/pages/tag.ts index ef79065d..ea1fe35e 100644 --- a/vhosts/blog/nuldoc-src/pages/tag.ts +++ b/vhosts/blog/nuldoc-src/pages/tag.ts @@ -6,7 +6,7 @@ import { slidePageEntry } from "../components/slide_page_entry.ts"; import { Config, getTagLabel } from "../config.ts"; import { el, text } from "../dom.ts"; import { Page } from "../page.ts"; -import { getPostCreatedDate } from "./post.ts"; +import { getPostPublishedDate } from "./post.ts"; import { TaggedPage } from "./tagged_page.ts"; export interface TagPage extends Page { @@ -41,7 +41,7 @@ export async function generateTagPage( const html = await pageLayout( { - metaCopyrightYear: getPostCreatedDate(pages[pages.length - 1]).year, + metaCopyrightYear: getPostPublishedDate(pages[pages.length - 1]).year, metaDescription: `タグ「${tagLabel}」のついた記事またはスライドの一覧`, metaKeywords: [tagLabel], metaTitle: `${pageTitle}|${config.blog.siteName}`, diff --git a/vhosts/blog/nuldoc-src/revision.ts b/vhosts/blog/nuldoc-src/revision.ts index e96d75de..a22b6bc4 100644 --- a/vhosts/blog/nuldoc-src/revision.ts +++ b/vhosts/blog/nuldoc-src/revision.ts @@ -33,4 +33,5 @@ export type Revision = { number: number; date: Date; remark: string; + isInternal: boolean; }; diff --git a/vhosts/blog/nuldoc-src/slide/parse.ts b/vhosts/blog/nuldoc-src/slide/parse.ts index 574dd4ba..b880ef0a 100644 --- a/vhosts/blog/nuldoc-src/slide/parse.ts +++ b/vhosts/blog/nuldoc-src/slide/parse.ts @@ -19,6 +19,7 @@ export async function parseSlideFile( revisions: { date: string; remark: string; + isInternal?: boolean; }[]; }; }; diff --git a/vhosts/blog/nuldoc-src/slide/slide.ts b/vhosts/blog/nuldoc-src/slide/slide.ts index 388c8c88..379d3bc7 100644 --- a/vhosts/blog/nuldoc-src/slide/slide.ts +++ b/vhosts/blog/nuldoc-src/slide/slide.ts @@ -89,7 +89,7 @@ export function createNewSlideFromTomlRootObject( ); } const revisions_ = revisions.map( - (x: { date: string; remark: string }, i: number) => { + (x: { date: string; remark: string; isInternal?: boolean }, i: number) => { const date = x.date ?? null; if (!date) { throw new SlideError( @@ -102,10 +102,12 @@ export function createNewSlideFromTomlRootObject( `[slide.new] 'remark' field not found`, ); } + const isInternal = x.isInternal ?? false; return { number: i + 1, date: stringToDate(date), - remark: remark, + remark, + isInternal, }; }, ); |
