Files
notesnook/docs/help/scripts/fork-page.mjs
Ammar Ahmed 52d6044e73 docs(help): rebuild the help site with VitePress (#10169)
* docs: new help built with vitepress.

* docs: improve docs home ui

Added a Go to Docs button on homepage
Added a searchbar for directly searching what you are looking for in the docs

* docs(help): wire up with build system & setup proper ci

* Clean up new documentation (#10174)

* Docs: Cleanup pass 1

Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net>

* docs: cleanup pass 2

Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net>

* docs: Fix vscode's manglement that I missed.

Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net>

* Update docs/help/contents/plans-and-limits.md

Co-authored-by: Abdullah Atta <thecodrr@protonmail.com>
Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net>

* Update docs/help/contents/rich-text-editor/outline-lists.md

Co-authored-by: Abdullah Atta <thecodrr@protonmail.com>
Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net>

* docs: Remove self-hosting guide from sidebar, and comments for reviewer.

Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net>

---------

Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net>
Co-authored-by: Abdullah Atta <thecodrr@protonmail.com>

* docs: some fixes

* ci: do not publish help on push

* docs(help): improve regional pricing & free trials

* docs: improve sidebar

* docs: some more fixes after re-review

* docs: improve search and nav

* docs: a few more fixes

* docs: fix tabs formatting compat with prettier

* docs: fix tabs formatting in various places

* docs: show correct plus button image for mobile

* docs: disable notesnook self hosting docs

* docs: update help docs with fixes

---------

Signed-off-by: Chloe Oletto <NeedsChloesure@riseup.net>
Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
Co-authored-by: Chloe Oletto <NeedsChloesure@riseup.net>
Co-authored-by: Abdullah Atta <thecodrr@protonmail.com>
2026-08-14 08:57:51 +05:00

69 lines
2.1 KiB
JavaScript

/**
* Preserves a page's current text for an older version, before you change it.
*
* npm run fork -- 3.3 organizing-notes/archive-notes
* npm run fork -- 3.3 app-lock.md
*
* Run this *before* editing the page at the root. It copies today's text into
* `contents/_versions/3.3/<page>`, so v3.3 keeps describing the old behaviour
* while the root moves on. Pages you never fork stay shared — there is exactly
* one copy of them in the repo.
*
* For a page that did not exist in an older version, add its path to
* `contents/_versions/<version>/_excluded.txt` instead.
*/
import { copyFileSync, existsSync, mkdirSync, readFileSync } from "fs";
import { dirname, join, relative } from "path";
import { fileURLToPath, pathToFileURL } from "url";
const HELP = dirname(dirname(fileURLToPath(import.meta.url)));
const CONTENTS = join(HELP, "contents");
const [version, rawPage] = process.argv.slice(2);
if (!version || !rawPage) {
console.error(
"Usage: npm run fork -- <version> <page>\n" +
" e.g. npm run fork -- 3.3 organizing-notes/archive-notes"
);
process.exit(1);
}
const { ARCHIVED } = await import(
pathToFileURL(join(HELP, ".vitepress", "versions.mjs")).href
);
if (!ARCHIVED.includes(version)) {
console.error(
`v${version} is not an archived version. Archived: ${
ARCHIVED.length ? ARCHIVED.join(", ") : "(none yet)"
}`
);
process.exit(1);
}
const page = rawPage.replace(/^\/+/, "").replace(/\.md$/, "") + ".md";
const source = join(CONTENTS, page);
if (!existsSync(source)) {
console.error(`No such page: contents/${page}`);
process.exit(1);
}
const dest = join(CONTENTS, "_versions", version, page);
if (existsSync(dest)) {
console.error(
`contents/${relative(CONTENTS, dest)} already exists — v${version} already has its own copy of this page.`
);
process.exit(1);
}
mkdirSync(dirname(dest), { recursive: true });
copyFileSync(source, dest);
console.log(
[
`Forked contents/${page} → contents/${relative(CONTENTS, dest)}`,
"",
`v${version} now keeps this text. Edit contents/${page} freely — your changes`,
"apply to the latest docs only."
].join("\n")
);