generated from nhcarrigan/template
Compare commits
2 Commits
bc3bceded8
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
330c4946b8
|
|||
|
99b5cb6935
|
@@ -20,6 +20,7 @@
|
||||
"@nhcarrigan/typescript-config": "4.0.0",
|
||||
"@types/node": "24.7.0",
|
||||
"eslint": "9.37.0",
|
||||
"puppeteer": "24.40.0",
|
||||
"tsx": "4.20.6",
|
||||
"typescript": "5.9.3"
|
||||
},
|
||||
|
||||
Generated
+60
-38
@@ -24,6 +24,9 @@ importers:
|
||||
eslint:
|
||||
specifier: 9.37.0
|
||||
version: 9.37.0
|
||||
puppeteer:
|
||||
specifier: 24.40.0
|
||||
version: 24.40.0(typescript@5.9.3)
|
||||
tsx:
|
||||
specifier: 4.20.6
|
||||
version: 4.20.6
|
||||
@@ -313,8 +316,8 @@ packages:
|
||||
resolution: {integrity: sha512-fdDH1LSGfZdTH2sxdpVMw31BanV28K/Gry0cVFxaNP77neJSkd82mM8ErPNYs9e+0O7SdHBLTDzDgwUuy18RnQ==}
|
||||
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
|
||||
|
||||
'@puppeteer/browsers@2.10.10':
|
||||
resolution: {integrity: sha512-3ZG500+ZeLql8rE0hjfhkycJjDj0pI/btEh3L9IkWUYcOrgP0xCNRq3HbtbqOPbvDhFaAWD88pDFtlLv8ns8gA==}
|
||||
'@puppeteer/browsers@2.13.0':
|
||||
resolution: {integrity: sha512-46BZJYJjc/WwmKjsvDFykHtXrtomsCIrwYQPOP7VfMJoZY2bsDF9oROBABR3paDjDcmkUye1Pb1BqdcdiipaWA==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
@@ -352,56 +355,67 @@ packages:
|
||||
resolution: {integrity: sha512-xRiOu9Of1FZ4SxVbB0iEDXc4ddIcjCv2aj03dmW8UrZIW7aIQ9jVJdLBIhxBI+MaTnGAKyvMwPwQnoOEvP7FgQ==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.52.4':
|
||||
resolution: {integrity: sha512-FbhM2p9TJAmEIEhIgzR4soUcsW49e9veAQCziwbR+XWB2zqJ12b4i/+hel9yLiD8pLncDH4fKIPIbt5238341Q==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-arm64-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-4n4gVwhPHR9q/g8lKCyz0yuaD0MvDf7dV4f9tHt0C73Mp8h38UCtSCSE6R9iBlTbXlmA8CjpsZoujhszefqueg==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-arm64-musl@4.52.4':
|
||||
resolution: {integrity: sha512-u0n17nGA0nvi/11gcZKsjkLj1QIpAuPFQbR48Subo7SmZJnGxDpspyw2kbpuoQnyK+9pwf3pAoEXerJs/8Mi9g==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-loong64-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-0G2c2lpYtbTuXo8KEJkDkClE/+/2AFPdPAbmaHoE870foRFs4pBrDehilMcrSScrN/fB/1HTaWO4bqw+ewBzMQ==}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-ppc64-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-teSACug1GyZHmPDv14VNbvZFX779UqWTsd7KtTM9JIZRDI5NUwYSIS30kzI8m06gOPB//jtpqlhmraQ68b5X2g==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-/MOEW3aHjjs1p4Pw1Xk4+3egRevx8Ji9N6HUIA1Ifh8Q+cg9dremvFCUbOX2Zebz80BwJIgCBUemjqhU5XI5Eg==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-musl@4.52.4':
|
||||
resolution: {integrity: sha512-1HHmsRyh845QDpEWzOFtMCph5Ts+9+yllCrREuBR/vg2RogAQGGBRC8lDPrPOMnrdOJ+mt1WLMOC2Kao/UwcvA==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-linux-s390x-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-seoeZp4L/6D1MUyjWkOMRU6/iLmCU2EjbMTyAG4oIOs1/I82Y5lTeaxW0KBfkUdHAWN7j25bpkt0rjnOgAcQcA==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-x64-gnu@4.52.4':
|
||||
resolution: {integrity: sha512-Wi6AXf0k0L7E2gteNsNHUs7UMwCIhsCTs6+tqQ5GPwVRWMaflqGec4Sd8n6+FNFDw9vGcReqk2KzBDhCa1DLYg==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@rollup/rollup-linux-x64-musl@4.52.4':
|
||||
resolution: {integrity: sha512-dtBZYjDmCQ9hW+WgEkaffvRRCKm767wWhxsFW3Lw86VXz/uJRuD438/XvbZT//B96Vs8oTA8Q4A0AfHbrxP9zw==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@rollup/rollup-openharmony-arm64@4.52.4':
|
||||
resolution: {integrity: sha512-1ox+GqgRWqaB1RnyZXL8PD6E5f7YyRUJYnCqKpNzxzP0TkaUh112NDrR9Tt+C8rJ4x5G9Mk8PQR3o7Ku2RKqKA==}
|
||||
@@ -811,6 +825,7 @@ packages:
|
||||
basic-ftp@5.0.5:
|
||||
resolution: {integrity: sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
deprecated: Security vulnerability fixed in 5.2.1, please upgrade
|
||||
|
||||
binary-extensions@2.3.0:
|
||||
resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}
|
||||
@@ -889,8 +904,8 @@ packages:
|
||||
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
|
||||
engines: {node: '>= 8.10.0'}
|
||||
|
||||
chromium-bidi@9.1.0:
|
||||
resolution: {integrity: sha512-rlUzQ4WzIAWdIbY/viPShhZU2n21CxDUgazXVbw4Hu1MwaeUSEksSeM6DqPgpRjCLXRk702AVRxJxoOz0dw4OA==}
|
||||
chromium-bidi@14.0.0:
|
||||
resolution: {integrity: sha512-9gYlLtS6tStdRWzrtXaTMnqcM4dudNegMXJxkR0I/CXObHalYeYcAMPrL19eroNZHtJ8DQmu1E+ZNOYu/IXMXw==}
|
||||
peerDependencies:
|
||||
devtools-protocol: '*'
|
||||
|
||||
@@ -1013,8 +1028,8 @@ packages:
|
||||
resolution: {integrity: sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==}
|
||||
engines: {node: '>= 14'}
|
||||
|
||||
devtools-protocol@0.0.1508733:
|
||||
resolution: {integrity: sha512-QJ1R5gtck6nDcdM+nlsaJXcelPEI7ZxSMw1ujHpO1c4+9l+Nue5qlebi9xO1Z2MGr92bFOQTW7/rrheh5hHxDg==}
|
||||
devtools-protocol@0.0.1581282:
|
||||
resolution: {integrity: sha512-nv7iKtNZQshSW2hKzYNr46nM/Cfh5SEvE2oV0/SEGgc9XupIY5ggf84Cz8eJIkBce7S3bmTAauFD6aysMpnqsQ==}
|
||||
|
||||
dir-glob@3.0.1:
|
||||
resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==}
|
||||
@@ -2013,12 +2028,12 @@ packages:
|
||||
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
puppeteer-core@24.23.0:
|
||||
resolution: {integrity: sha512-yl25C59gb14sOdIiSnJ08XiPP+O2RjuyZmEG+RjYmCXO7au0jcLf7fRiyii96dXGUBW7Zwei/mVKfxMx/POeFw==}
|
||||
puppeteer-core@24.40.0:
|
||||
resolution: {integrity: sha512-MWL3XbUCfVgGR0gRsidzT6oKJT2QydPLhMITU6HoVWiiv4gkb6gJi3pcdAa8q4HwjBTbqISOWVP4aJiiyUJvag==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
puppeteer@24.23.0:
|
||||
resolution: {integrity: sha512-BVR1Lg8sJGKXY79JARdIssFWK2F6e1j+RyuJP66w4CUmpaXjENicmA3nNpUXA8lcTdDjAndtP+oNdni3T/qQqA==}
|
||||
puppeteer@24.40.0:
|
||||
resolution: {integrity: sha512-IxQbDq93XHVVLWHrAkFP7F7iHvb9o0mgfsSIMlhHb+JM+JjM1V4v4MNSQfcRWJopx9dsNOr9adYv0U5fm9BJBQ==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
@@ -2140,6 +2155,11 @@ packages:
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
|
||||
semver@7.7.4:
|
||||
resolution: {integrity: sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==}
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
|
||||
serve-handler@6.1.6:
|
||||
resolution: {integrity: sha512-x5RL9Y2p5+Sh3D38Fh9i/iQ5ZK+e4xuXRd/pGbM4D13tgo/MGwbttUk8emytcr1YYzBYs+apnUngBDFYfpjPuQ==}
|
||||
|
||||
@@ -2426,8 +2446,8 @@ packages:
|
||||
resolution: {integrity: sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
typed-query-selector@2.12.0:
|
||||
resolution: {integrity: sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg==}
|
||||
typed-query-selector@2.12.1:
|
||||
resolution: {integrity: sha512-uzR+FzI8qrUEIu96oaeBJmd9E7CFEiQ3goA5qCVgc4s5llSubcfGHq9yUstZx/k4s9dXHVKsE35YWoFyvEqEHA==}
|
||||
|
||||
typescript@5.9.3:
|
||||
resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==}
|
||||
@@ -2526,8 +2546,8 @@ packages:
|
||||
jsdom:
|
||||
optional: true
|
||||
|
||||
webdriver-bidi-protocol@0.3.6:
|
||||
resolution: {integrity: sha512-mlGndEOA9yK9YAbvtxaPTqdi/kaCWYYfwrZvGzcmkr/3lWM+tQj53BxtpVd6qbC6+E5OnHXgCcAhre6AkXzxjA==}
|
||||
webdriver-bidi-protocol@0.4.1:
|
||||
resolution: {integrity: sha512-ARrjNjtWRRs2w4Tk7nqrf2gBI0QXWuOmMCx2hU+1jUt6d00MjMxURrhxhGbrsoiZKJrhTSTzbIrc554iKI10qw==}
|
||||
|
||||
which-boxed-primitive@1.1.1:
|
||||
resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==}
|
||||
@@ -2570,8 +2590,8 @@ packages:
|
||||
wrappy@1.0.2:
|
||||
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
||||
|
||||
ws@8.18.3:
|
||||
resolution: {integrity: sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==}
|
||||
ws@8.20.0:
|
||||
resolution: {integrity: sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
peerDependencies:
|
||||
bufferutil: ^4.0.1
|
||||
@@ -2830,13 +2850,13 @@ snapshots:
|
||||
|
||||
'@pkgr/core@0.1.2': {}
|
||||
|
||||
'@puppeteer/browsers@2.10.10':
|
||||
'@puppeteer/browsers@2.13.0':
|
||||
dependencies:
|
||||
debug: 4.4.3
|
||||
extract-zip: 2.0.1
|
||||
progress: 2.0.3
|
||||
proxy-agent: 6.5.0
|
||||
semver: 7.7.2
|
||||
semver: 7.7.4
|
||||
tar-fs: 3.1.1
|
||||
yargs: 17.7.2
|
||||
transitivePeerDependencies:
|
||||
@@ -3449,9 +3469,9 @@ snapshots:
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
|
||||
chromium-bidi@9.1.0(devtools-protocol@0.0.1508733):
|
||||
chromium-bidi@14.0.0(devtools-protocol@0.0.1581282):
|
||||
dependencies:
|
||||
devtools-protocol: 0.0.1508733
|
||||
devtools-protocol: 0.0.1581282
|
||||
mitt: 3.0.1
|
||||
zod: 3.25.76
|
||||
|
||||
@@ -3567,7 +3587,7 @@ snapshots:
|
||||
escodegen: 2.1.0
|
||||
esprima: 4.0.1
|
||||
|
||||
devtools-protocol@0.0.1508733: {}
|
||||
devtools-protocol@0.0.1581282: {}
|
||||
|
||||
dir-glob@3.0.1:
|
||||
dependencies:
|
||||
@@ -4503,7 +4523,7 @@ snapshots:
|
||||
iconv-lite: 0.6.3
|
||||
listr: 0.14.3
|
||||
marked: 4.3.0
|
||||
puppeteer: 24.23.0(typescript@5.9.3)
|
||||
puppeteer: 24.40.0(typescript@5.9.3)
|
||||
semver: 7.7.2
|
||||
serve-handler: 6.1.6
|
||||
transitivePeerDependencies:
|
||||
@@ -4759,15 +4779,15 @@ snapshots:
|
||||
|
||||
punycode@2.3.1: {}
|
||||
|
||||
puppeteer-core@24.23.0:
|
||||
puppeteer-core@24.40.0:
|
||||
dependencies:
|
||||
'@puppeteer/browsers': 2.10.10
|
||||
chromium-bidi: 9.1.0(devtools-protocol@0.0.1508733)
|
||||
'@puppeteer/browsers': 2.13.0
|
||||
chromium-bidi: 14.0.0(devtools-protocol@0.0.1581282)
|
||||
debug: 4.4.3
|
||||
devtools-protocol: 0.0.1508733
|
||||
typed-query-selector: 2.12.0
|
||||
webdriver-bidi-protocol: 0.3.6
|
||||
ws: 8.18.3
|
||||
devtools-protocol: 0.0.1581282
|
||||
typed-query-selector: 2.12.1
|
||||
webdriver-bidi-protocol: 0.4.1
|
||||
ws: 8.20.0
|
||||
transitivePeerDependencies:
|
||||
- bare-buffer
|
||||
- bufferutil
|
||||
@@ -4775,14 +4795,14 @@ snapshots:
|
||||
- supports-color
|
||||
- utf-8-validate
|
||||
|
||||
puppeteer@24.23.0(typescript@5.9.3):
|
||||
puppeteer@24.40.0(typescript@5.9.3):
|
||||
dependencies:
|
||||
'@puppeteer/browsers': 2.10.10
|
||||
chromium-bidi: 9.1.0(devtools-protocol@0.0.1508733)
|
||||
'@puppeteer/browsers': 2.13.0
|
||||
chromium-bidi: 14.0.0(devtools-protocol@0.0.1581282)
|
||||
cosmiconfig: 9.0.0(typescript@5.9.3)
|
||||
devtools-protocol: 0.0.1508733
|
||||
puppeteer-core: 24.23.0
|
||||
typed-query-selector: 2.12.0
|
||||
devtools-protocol: 0.0.1581282
|
||||
puppeteer-core: 24.40.0
|
||||
typed-query-selector: 2.12.1
|
||||
transitivePeerDependencies:
|
||||
- bare-buffer
|
||||
- bufferutil
|
||||
@@ -4937,6 +4957,8 @@ snapshots:
|
||||
|
||||
semver@7.7.2: {}
|
||||
|
||||
semver@7.7.4: {}
|
||||
|
||||
serve-handler@6.1.6:
|
||||
dependencies:
|
||||
bytes: 3.0.0
|
||||
@@ -5290,7 +5312,7 @@ snapshots:
|
||||
possible-typed-array-names: 1.1.0
|
||||
reflect.getprototypeof: 1.0.10
|
||||
|
||||
typed-query-selector@2.12.0: {}
|
||||
typed-query-selector@2.12.1: {}
|
||||
|
||||
typescript@5.9.3: {}
|
||||
|
||||
@@ -5393,7 +5415,7 @@ snapshots:
|
||||
- tsx
|
||||
- yaml
|
||||
|
||||
webdriver-bidi-protocol@0.3.6: {}
|
||||
webdriver-bidi-protocol@0.4.1: {}
|
||||
|
||||
which-boxed-primitive@1.1.1:
|
||||
dependencies:
|
||||
@@ -5460,7 +5482,7 @@ snapshots:
|
||||
|
||||
wrappy@1.0.2: {}
|
||||
|
||||
ws@8.18.3: {}
|
||||
ws@8.20.0: {}
|
||||
|
||||
y18n@5.0.8: {}
|
||||
|
||||
|
||||
+43
-28
@@ -4,13 +4,7 @@
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
|
||||
import {
|
||||
readFile,
|
||||
appendFile,
|
||||
writeFile,
|
||||
readdir,
|
||||
unlink,
|
||||
} from "node:fs/promises";
|
||||
import { readFile, writeFile, readdir, unlink } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { mdToPdf } from "md-to-pdf";
|
||||
import order from "../data/order.json" assert { type: "json" };
|
||||
@@ -46,38 +40,59 @@ const sortFiles = (a: string, b: string): number => {
|
||||
return aIndex - bIndex;
|
||||
};
|
||||
|
||||
interface FileEntry {
|
||||
body: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
const slugify = (text: string): string => {
|
||||
return text.
|
||||
toLowerCase().
|
||||
replaceAll(/[^\w\s-]/gu, "").
|
||||
replaceAll(/\s+/gu, "-");
|
||||
};
|
||||
|
||||
const processFile = async(file: string): Promise<FileEntry> => {
|
||||
const content = await readFile(file, "utf8");
|
||||
const titleMatch = /^title: (?<title>.*)/mu.exec(content);
|
||||
const title = titleMatch?.groups?.title ?? "Unknown";
|
||||
const body = content.
|
||||
replace(/^---\n[\S\s]*?\n---\n/u, "").
|
||||
trim().
|
||||
replace(/^#+ --.*--/u, "").
|
||||
trim().
|
||||
replaceAll(/^:::.*$/gmu, "").
|
||||
trim();
|
||||
return { body, title };
|
||||
};
|
||||
|
||||
const rollupFiles = async(
|
||||
inputDirectory: string,
|
||||
outputFile: string,
|
||||
): Promise<void> => {
|
||||
try {
|
||||
console.log("Process started...");
|
||||
await writeFile(outputFile, `${starterText}\n`);
|
||||
console.log("Reading content directory...");
|
||||
const unsortedFiles = await readDirectoryRecursively(inputDirectory);
|
||||
console.log(unsortedFiles);
|
||||
const files = unsortedFiles.toSorted(sortFiles);
|
||||
console.log("Files found, processing...");
|
||||
for (const file of files) {
|
||||
if (file === ".gitkeep") {
|
||||
continue;
|
||||
}
|
||||
if (file.endsWith(".md")) {
|
||||
const content = await readFile(file, "utf8");
|
||||
const strippedFrontmatter = content.
|
||||
replace(/^---\n[\S\s]*?\n---\n/, "").
|
||||
trim();
|
||||
// Title is in front matter
|
||||
const title = /^title: (?<title>.*)/m.exec(content)?.groups?.title;
|
||||
const strippedFccHeadings = strippedFrontmatter.
|
||||
replace(/^#+ --.*--/, "").
|
||||
trim();
|
||||
await appendFile(
|
||||
outputFile,
|
||||
`---\n\n# ${title ?? "Unknown"}\n${strippedFccHeadings}\n\n`,
|
||||
const mdFiles = files.filter((file) => {
|
||||
return file.endsWith(".md");
|
||||
});
|
||||
const entries = await Promise.all(
|
||||
mdFiles.map(async(file) => {
|
||||
return await processFile(file);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
const tocLines = entries.map(({ title }) => {
|
||||
return `- [${title}](#${slugify(title)})`;
|
||||
});
|
||||
const toc = `## Table of Contents\n\n${tocLines.join("\n")}\n\n---`;
|
||||
const sections = entries.map(({ body, title }) => {
|
||||
return `---\n\n# ${title}\n\n${body}\n\n`;
|
||||
});
|
||||
|
||||
await writeFile(outputFile, `${starterText}\n${toc}\n\n${sections.join("")}`);
|
||||
console.log(`Successfully rolled up files into ${outputFile}`);
|
||||
} catch (error) {
|
||||
console.error("Error rolling up files:", error);
|
||||
|
||||
Reference in New Issue
Block a user