diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-10-06 01:42:40 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-10-06 01:42:40 +0900 |
| commit | 706e7a1230f7c55ebf1ebf4f2404a0d3a07d5737 (patch) | |
| tree | bea6d9295b259bbc600a32d806c9ef7dd767e9eb /services | |
| parent | c05c8681c137a3ee7e7170f9bc883cdb22a0b3d1 (diff) | |
| download | nsfisis.dev-706e7a1230f7c55ebf1ebf4f2404a0d3a07d5737.tar.gz nsfisis.dev-706e7a1230f7c55ebf1ebf4f2404a0d3a07d5737.tar.zst nsfisis.dev-706e7a1230f7c55ebf1ebf4f2404a0d3a07d5737.zip | |
feat(blog/nuldoc): copy asset files on build
Diffstat (limited to 'services')
| -rw-r--r-- | services/blog/nuldoc-src/commands/build.ts | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/services/blog/nuldoc-src/commands/build.ts b/services/blog/nuldoc-src/commands/build.ts index 3f765441..8c8de8f5 100644 --- a/services/blog/nuldoc-src/commands/build.ts +++ b/services/blog/nuldoc-src/commands/build.ts @@ -1,4 +1,4 @@ -import { dirname, join, joinGlobs } from "@std/path"; +import { dirname, join, joinGlobs, relative } from "@std/path"; import { ensureDir, expandGlob } from "@std/fs"; import { generateFeedPageFromEntries } from "../generators/atom.ts"; import { Config, getTagLabel } from "../config.ts"; @@ -34,7 +34,8 @@ export async function runBuildCommand(config: Config) { await buildNotFoundPage(config); await buildFeedOfAllContents(posts, slides, config); await copyStaticFiles(config); - await copyAssetFiles(slides, config); + await copySlidesFiles(slides, config); + await copyAssetFiles(config); } async function buildPostPages(config: Config): Promise<PostPage[]> { @@ -236,7 +237,7 @@ async function copyStaticFiles(config: Config) { } } -async function copyAssetFiles(slides: SlidePage[], config: Config) { +async function copySlidesFiles(slides: SlidePage[], config: Config) { const cwd = Deno.cwd(); const contentDir = join(cwd, config.locations.contentDir); const destDir = join(cwd, config.locations.destDir); @@ -249,6 +250,31 @@ async function copyAssetFiles(slides: SlidePage[], config: Config) { } } +async function copyAssetFiles(config: Config) { + const cwd = Deno.cwd(); + const contentDir = join(cwd, config.locations.contentDir); + const destDir = join(cwd, config.locations.destDir); + + const globPattern = joinGlobs([contentDir, "**", "*"]); + for await (const { isFile, path } of expandGlob(globPattern)) { + if (!isFile) continue; + + // Skip .dj, .toml, .pdf files + if ( + path.endsWith(".dj") || + path.endsWith(".toml") || + path.endsWith(".pdf") + ) { + continue; + } + + const src = path; + const dst = join(destDir, relative(contentDir, path)); + await ensureDir(dirname(dst)); + await Deno.copyFile(src, dst); + } +} + async function writePage(page: Page, config: Config) { const destFilePath = join( Deno.cwd(), |
