diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-11-27 06:41:24 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-11-27 06:41:24 +0900 |
| commit | bce9f9e1d774ee50aceffd347050e263782b55a4 (patch) | |
| tree | c09507c59afc279de043349f565a38dac1ca007d /services/nuldoc/nuldoc-src | |
| parent | 83b1286354e0f5e83927c8fb35a584e587b5530b (diff) | |
| download | nsfisis.dev-bce9f9e1d774ee50aceffd347050e263782b55a4.tar.gz nsfisis.dev-bce9f9e1d774ee50aceffd347050e263782b55a4.tar.zst nsfisis.dev-bce9f9e1d774ee50aceffd347050e263782b55a4.zip | |
feat(nuldoc): serve original Markdown files
Diffstat (limited to 'services/nuldoc/nuldoc-src')
| -rw-r--r-- | services/nuldoc/nuldoc-src/commands/build.ts | 14 | ||||
| -rw-r--r-- | services/nuldoc/nuldoc-src/generators/post.ts | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/services/nuldoc/nuldoc-src/commands/build.ts b/services/nuldoc/nuldoc-src/commands/build.ts index 2b67d2b..2a9295d 100644 --- a/services/nuldoc/nuldoc-src/commands/build.ts +++ b/services/nuldoc/nuldoc-src/commands/build.ts @@ -41,6 +41,7 @@ export async function runBuildCommand(config: Config) { await copySlidesFiles(slides, config); await copyBlogAssetFiles(config); await copySlidesAssetFiles(config); + await copyPostSourceFiles(posts, config); } async function buildPostPages(config: Config): Promise<PostPage[]> { @@ -316,3 +317,16 @@ async function writePage(page: Page, config: Config) { await ensureDir(dirname(destFilePath)); await Deno.writeTextFile(destFilePath, render(page.root, page.renderer)); } + +async function copyPostSourceFiles(posts: PostPage[], config: Config) { + const cwd = Deno.cwd(); + const contentDir = join(cwd, config.locations.contentDir); + const destDir = join(cwd, config.locations.destDir, "blog"); + + for (const post of posts) { + const src = post.sourceFilePath; + const dst = join(destDir, relative(contentDir, src)); + await ensureDir(dirname(dst)); + await Deno.copyFile(src, dst); + } +} diff --git a/services/nuldoc/nuldoc-src/generators/post.ts b/services/nuldoc/nuldoc-src/generators/post.ts index 2f466b9..8720562 100644 --- a/services/nuldoc/nuldoc-src/generators/post.ts +++ b/services/nuldoc/nuldoc-src/generators/post.ts @@ -13,6 +13,7 @@ export interface PostPage extends Page { published: Date; updated: Date; uuid: string; + sourceFilePath: string; } export function getPostPublishedDate(page: { revisions: Revision[] }): Date { @@ -57,5 +58,6 @@ export async function generatePostPage( published: getPostPublishedDate(doc), updated: getPostUpdatedDate(doc), uuid: doc.uuid, + sourceFilePath: doc.sourceFilePath, }; } |
