diff options
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, }; } |
