-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add a predocs script creating symlinks for docs generator
- Loading branch information
Showing
4 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/browser/ | ||
/dist/ | ||
/docs/ | ||
/docs-slate/ | ||
/lib/ | ||
/package-lock.json | ||
|
Submodule docs-slate
updated
11 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env node | ||
|
||
import { lstat, mkdir, readdir, readFile, symlink, rm } from 'node:fs/promises' | ||
import { resolve } from 'node:path' | ||
import { parseAllDocuments } from '../dist/index.js' | ||
|
||
const source = 'docs' | ||
const target = 'docs-slate/source' | ||
|
||
// Create symlink for index.html.md | ||
const indexSource = resolve(source, 'index.html.md') | ||
const indexTarget = resolve(target, 'index.html.md') | ||
try { | ||
const prevIndex = await lstat(indexTarget) | ||
if (prevIndex.isSymbolicLink()) await rm(indexTarget) | ||
} catch {} | ||
await symlink(indexSource, indexTarget, 'file') | ||
|
||
// Create symlinks for included sections | ||
const includesDir = resolve(target, 'includes') | ||
try { | ||
await mkdir(includesDir) | ||
} catch { | ||
for (const ent of await readdir(includesDir, { withFileTypes: true })) { | ||
if (ent.isSymbolicLink()) await rm(resolve(includesDir, ent.name)) | ||
} | ||
} | ||
const [indexDoc] = parseAllDocuments(await readFile(indexSource, 'utf-8')) | ||
for (const { value } of indexDoc.get('includes').items) { | ||
const name = `${value}.md` | ||
await symlink(resolve(source, name), resolve(includesDir, name), 'file') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters