diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-03-18 18:09:50 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-03-18 18:12:23 +0900 |
| commit | 12035272d44d92cd2360aeff88d499db67fe1949 (patch) | |
| tree | b9366110badb650b7d0af84330dd69df4bd71bcf /nuldoc-src/docbook | |
| parent | b98d324fe7eb37e7004926843feede7e636c3301 (diff) | |
| download | blog.nsfisis.dev-12035272d44d92cd2360aeff88d499db67fe1949.tar.gz blog.nsfisis.dev-12035272d44d92cd2360aeff88d499db67fe1949.tar.zst blog.nsfisis.dev-12035272d44d92cd2360aeff88d499db67fe1949.zip | |
refactor: use Page instead of Document
Diffstat (limited to 'nuldoc-src/docbook')
| -rw-r--r-- | nuldoc-src/docbook/document.ts | 56 |
1 files changed, 11 insertions, 45 deletions
diff --git a/nuldoc-src/docbook/document.ts b/nuldoc-src/docbook/document.ts index ae3159a..9f3221b 100644 --- a/nuldoc-src/docbook/document.ts +++ b/nuldoc-src/docbook/document.ts @@ -9,7 +9,7 @@ import { innerText, } from "../dom.ts"; -export class Document { +export type Document = { root: Element; sourceFilePath: string; link: string; @@ -17,41 +17,7 @@ export class Document { summary: string; // TODO: should it be markup text? tags: string[]; revisions: Revision[]; - - constructor( - root: Element, - sourceFilePath: string, - link: string, - title: string, - summary: string, - tags: string[], - revisions: Revision[], - ) { - this.root = root; - this.sourceFilePath = sourceFilePath; - this.link = link; - this.title = title; - this.summary = summary; - this.tags = tags; - this.revisions = revisions; - } - - getLatestRevision(): Revision { - return this.revisions[this.revisions.length - 1]; - } - - getOldestRevision(): Revision { - return this.revisions[0]; - } - - getUpdatedDate(): string { - return this.getLatestRevision().date; - } - - getCreatedDate(): string { - return this.getOldestRevision().date; - } -} +}; export function createNewDocumentFromRootElement( root: Element, @@ -130,13 +96,13 @@ export function createNewDocumentFromRootElement( const cwd = Deno.cwd(); const contentDir = join(cwd, config.locations.contentDir); const link = sourceFilePath.replace(contentDir, "").replace(".xml", "/"); - return new Document( - root, - sourceFilePath, - link, - title, - summary, - tags, - revisions, - ); + return { + root: root, + sourceFilePath: sourceFilePath, + link: link, + title: title, + summary: summary, + tags: tags, + revisions: revisions, + }; } |
