create-cantip 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +19 -0
- package/index.js +84 -0
- package/package.json +37 -0
- package/template/README.md +34 -0
- package/template/_gitignore +17 -0
- package/template/_package.json +16 -0
- package/template/docs/intro.md +25 -0
- package/template/docs.config.ts +46 -0
- package/template/public/favicon.svg +1 -0
- package/template/public/logo-dark.svg +1 -0
- package/template/public/logo-light.svg +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sedokina
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# create-cantip
|
|
2
|
+
|
|
3
|
+
Scaffold a new [cantip](https://www.npmjs.com/package/cantip) documentation site.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm create cantip my-docs
|
|
7
|
+
cd my-docs
|
|
8
|
+
npm install
|
|
9
|
+
npm run dev
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This generates a minimal starter: `docs.config.ts`, a `docs/` folder with a
|
|
13
|
+
sample page, default `public/` assets, and a `package.json` wired to `cantip`.
|
|
14
|
+
|
|
15
|
+
Then edit `docs.config.ts` to configure your site and drop markdown into `docs/`.
|
|
16
|
+
|
|
17
|
+
## License
|
|
18
|
+
|
|
19
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `create-cantip` — scaffold a new cantip docs site.
|
|
4
|
+
*
|
|
5
|
+
* npm create cantip my-docs
|
|
6
|
+
* npm create cantip # prompts/defaults to ./my-docs
|
|
7
|
+
*
|
|
8
|
+
* Copies the `template/` directory into the target, renaming `_package.json` →
|
|
9
|
+
* `package.json` and `_gitignore` → `.gitignore`, and substituting the project
|
|
10
|
+
* name + cantip version. Refuses to overwrite a non-empty target.
|
|
11
|
+
*/
|
|
12
|
+
import { fileURLToPath } from 'node:url'
|
|
13
|
+
import fs from 'node:fs'
|
|
14
|
+
import path from 'node:path'
|
|
15
|
+
|
|
16
|
+
const HERE = path.dirname(fileURLToPath(import.meta.url))
|
|
17
|
+
const TEMPLATE_DIR = path.join(HERE, 'template')
|
|
18
|
+
|
|
19
|
+
/** cantip version to depend on — mirror create-cantip's own version. */
|
|
20
|
+
function cantipVersion() {
|
|
21
|
+
try {
|
|
22
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(HERE, 'package.json'), 'utf8'))
|
|
23
|
+
// Pin to the same major.minor line so a fresh scaffold matches this CLI.
|
|
24
|
+
return `^${pkg.version}`
|
|
25
|
+
} catch {
|
|
26
|
+
return 'latest'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Files that need their leading underscore stripped (npm strips dotfiles from publishes). */
|
|
31
|
+
const RENAME = new Map([
|
|
32
|
+
['_package.json', 'package.json'],
|
|
33
|
+
['_gitignore', '.gitignore'],
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
/** Apply name/version substitutions to text files. */
|
|
37
|
+
function substitute(content, projectName) {
|
|
38
|
+
return content
|
|
39
|
+
.replaceAll('__PROJECT_NAME__', projectName)
|
|
40
|
+
.replaceAll('__CANTIP_VERSION__', cantipVersion())
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Files we run substitution on (others are copied verbatim — e.g. SVGs). */
|
|
44
|
+
const SUBSTITUTE_EXT = new Set(['.json', '.md', '.ts', '.tsx', ''])
|
|
45
|
+
|
|
46
|
+
function copyDir(srcDir, destDir, projectName) {
|
|
47
|
+
fs.mkdirSync(destDir, { recursive: true })
|
|
48
|
+
for (const entry of fs.readdirSync(srcDir, { withFileTypes: true })) {
|
|
49
|
+
const srcPath = path.join(srcDir, entry.name)
|
|
50
|
+
const outName = RENAME.get(entry.name) ?? entry.name
|
|
51
|
+
const destPath = path.join(destDir, outName)
|
|
52
|
+
if (entry.isDirectory()) {
|
|
53
|
+
copyDir(srcPath, destPath, projectName)
|
|
54
|
+
} else if (SUBSTITUTE_EXT.has(path.extname(entry.name))) {
|
|
55
|
+
fs.writeFileSync(destPath, substitute(fs.readFileSync(srcPath, 'utf8'), projectName))
|
|
56
|
+
} else {
|
|
57
|
+
fs.copyFileSync(srcPath, destPath)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function main() {
|
|
63
|
+
const targetArg = process.argv[2] || 'my-docs'
|
|
64
|
+
const targetDir = path.resolve(process.cwd(), targetArg)
|
|
65
|
+
const projectName = path.basename(targetDir)
|
|
66
|
+
|
|
67
|
+
if (fs.existsSync(targetDir) && fs.readdirSync(targetDir).length > 0) {
|
|
68
|
+
console.error(`✖ Target directory "${targetArg}" exists and is not empty. Aborting.`)
|
|
69
|
+
process.exit(1)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
console.log(`▶ Scaffolding a cantip docs site in ${targetDir}…`)
|
|
73
|
+
copyDir(TEMPLATE_DIR, targetDir, projectName)
|
|
74
|
+
|
|
75
|
+
console.log(
|
|
76
|
+
`\n✔ Done. Next steps:\n\n` +
|
|
77
|
+
` cd ${targetArg}\n` +
|
|
78
|
+
` npm install\n` +
|
|
79
|
+
` npm run dev\n\n` +
|
|
80
|
+
`Edit docs.config.ts to configure your site, and drop markdown into content/.\n`,
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
main()
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-cantip",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "Scaffold a new cantip documentation site (`npm create cantip my-docs`).",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"cantip",
|
|
8
|
+
"documentation",
|
|
9
|
+
"docs",
|
|
10
|
+
"scaffold",
|
|
11
|
+
"create",
|
|
12
|
+
"starter"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Sedokina",
|
|
16
|
+
"homepage": "https://github.com/Sedokina/cantip/tree/main/packages/create-cantip#readme",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/Sedokina/cantip.git",
|
|
20
|
+
"directory": "packages/create-cantip"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/Sedokina/cantip/issues"
|
|
24
|
+
},
|
|
25
|
+
"bin": {
|
|
26
|
+
"create-cantip": "./index.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"index.js",
|
|
30
|
+
"template",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=20"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# __PROJECT_NAME__
|
|
2
|
+
|
|
3
|
+
A documentation site built with [cantip](https://www.npmjs.com/package/cantip).
|
|
4
|
+
|
|
5
|
+
## Develop
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install
|
|
9
|
+
npm run dev # generate content + start the dev server
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Build & serve
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm run build # generate + production build
|
|
16
|
+
npm run start # serve the build
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Add content
|
|
20
|
+
|
|
21
|
+
- Drop `.md` files into `docs/` — each becomes a page at its file path.
|
|
22
|
+
- Or edit `docs.config.ts` to add `projects`, each pointing `source` at a folder,
|
|
23
|
+
a git submodule, or any path.
|
|
24
|
+
|
|
25
|
+
## Customize
|
|
26
|
+
|
|
27
|
+
Everything lives in `docs.config.ts`:
|
|
28
|
+
|
|
29
|
+
- **Branding** — `site.title`, `site.logo`, `site.favicon`, `site.defaultTheme`.
|
|
30
|
+
- **Theme** — `theme.colors` (OKLCH tokens), no CSS editing required.
|
|
31
|
+
- **Components** — `components` maps `Home`/`DocPage`/`TopBar`/`Toc` to your own
|
|
32
|
+
`.tsx` files.
|
|
33
|
+
|
|
34
|
+
See the cantip docs for the full config reference.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__PROJECT_NAME__",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "0.0.0",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"generate": "cantip generate",
|
|
8
|
+
"dev": "cantip dev",
|
|
9
|
+
"build": "cantip build",
|
|
10
|
+
"start": "cantip start",
|
|
11
|
+
"typecheck": "cantip typecheck"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"cantip": "__CANTIP_VERSION__"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Welcome
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Welcome to your docs
|
|
6
|
+
|
|
7
|
+
This page lives at `docs/intro.md` and is served at **`/intro/`**.
|
|
8
|
+
|
|
9
|
+
Drop more `.md` files into `docs/` — each becomes a page at its file path.
|
|
10
|
+
Folders become sections in the sidebar.
|
|
11
|
+
|
|
12
|
+
## What you can write
|
|
13
|
+
|
|
14
|
+
Standard Markdown, plus:
|
|
15
|
+
|
|
16
|
+
- **Wikilinks** — `[[another-page]]` to link between docs.
|
|
17
|
+
- **Callouts** — Obsidian-style `> [!note]` blocks.
|
|
18
|
+
- **Math** — `$inline$` and `$$block$$` via KaTeX.
|
|
19
|
+
- **Tables, code blocks, task lists** — full GitHub-Flavored Markdown.
|
|
20
|
+
|
|
21
|
+
## Next steps
|
|
22
|
+
|
|
23
|
+
1. Edit `docs.config.ts` to set your title, theme, and content sources.
|
|
24
|
+
2. Run `npx cantip dev` and open the printed URL.
|
|
25
|
+
3. Add pages, or point a project `source` at a git submodule / existing folder.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineConfig } from 'cantip/config'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Your docs site config. Every field is optional — start minimal and add as you
|
|
5
|
+
* grow. Run `npx cantip dev` after editing.
|
|
6
|
+
*
|
|
7
|
+
* Content sources: each `project` points `source` at a directory of markdown
|
|
8
|
+
* (a loose folder, a git submodule, or any path). The project `id` becomes the
|
|
9
|
+
* first URL segment. Or drop loose files into ./content and enable `general`
|
|
10
|
+
* below to serve them at the root with no project concept at all.
|
|
11
|
+
*/
|
|
12
|
+
export default defineConfig({
|
|
13
|
+
site: {
|
|
14
|
+
title: 'My Docs',
|
|
15
|
+
description: 'Documentation built with cantip.',
|
|
16
|
+
// Drives sort order + search tokenisation. e.g. 'en', 'ru', 'de'.
|
|
17
|
+
lang: 'en',
|
|
18
|
+
defaultTheme: 'dark', // 'dark' | 'light'
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
// The no-project bucket: loose markdown in ./docs, served at the root
|
|
22
|
+
// (e.g. docs/intro.md → /intro/). Remove this and use `projects` instead if
|
|
23
|
+
// you want multiple named docsets with a project switcher. (Note: keep your
|
|
24
|
+
// source dir distinct from ./content — that name is the generated output.)
|
|
25
|
+
general: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
source: './docs',
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
// Named projects (uncomment to use instead of / alongside `general`):
|
|
31
|
+
// projects: [
|
|
32
|
+
// {
|
|
33
|
+
// id: 'guide',
|
|
34
|
+
// name: 'User Guide',
|
|
35
|
+
// source: './content/guide', // loose folder, submodule, or any path
|
|
36
|
+
// description: 'How to use the product.',
|
|
37
|
+
// canvas: false, // set true to ingest .canvas files too
|
|
38
|
+
// },
|
|
39
|
+
// ],
|
|
40
|
+
|
|
41
|
+
// Override the brand color (and any other OKLCH token) without touching CSS:
|
|
42
|
+
// theme: { colors: { dark: { '--brand': 'oklch(0.7 0.2 250)' } } },
|
|
43
|
+
|
|
44
|
+
// Swap any built-in component for your own (Home, DocPage, TopBar, Toc):
|
|
45
|
+
// components: { Home: './app/MyHome.tsx' },
|
|
46
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="7" fill="#4C3FB0"/><path d="M9 23V9h3v6l5-6h3.6l-5.2 6.2L24 23h-3.8l-4.2-5.6L12 19.8V23H9Z" fill="#fff"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 24" height="24"><rect width="24" height="24" rx="6" fill="#7c6ff0"/><path d="M7 18V6h2.4v4.8L13 6h2.9l-4.2 5L16 18h-3l-3.3-4.5L9.4 15.4V18H7Z" fill="#fff"/><text x="32" y="17" font-family="system-ui,sans-serif" font-size="14" font-weight="600" fill="#f5f5f5">My Docs</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 24" height="24"><rect width="24" height="24" rx="6" fill="#4C3FB0"/><path d="M7 18V6h2.4v4.8L13 6h2.9l-4.2 5L16 18h-3l-3.3-4.5L9.4 15.4V18H7Z" fill="#fff"/><text x="32" y="17" font-family="system-ui,sans-serif" font-size="14" font-weight="600" fill="#1a1a1a">My Docs</text></svg>
|