diff --git a/bin/create-docforge.js b/bin/create-docforge.js new file mode 100755 index 0000000..dd74768 --- /dev/null +++ b/bin/create-docforge.js @@ -0,0 +1,45 @@ +#!/usr/bin/env node +const fs = require('fs'); +const path = require('path'); +const { execSync } = require('child_process'); + +function copyDir(src, dest) { + fs.mkdirSync(dest, { recursive: true }); + for (const entry of fs.readdirSync(src, { withFileTypes: true })) { + const srcPath = path.join(src, entry.name); + const destPath = path.join(dest, entry.name); + if (entry.isDirectory()) { + copyDir(srcPath, destPath); + } else { + fs.copyFileSync(srcPath, destPath); + } + } +} + +function main() { + const args = process.argv.slice(2); + const install = args.includes('--install'); + const targetArg = args.find(a => !a.startsWith('-')) || '.'; + const targetDir = path.resolve(process.cwd(), targetArg); + + const templateDir = path.join(__dirname, '..', 'starter'); + copyDir(templateDir, targetDir); + + const pkgPath = path.join(targetDir, 'package.json'); + if (fs.existsSync(pkgPath)) { + const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); + const version = require('../package.json').version; + if (pkg.dependencies && pkg.dependencies.docforge) + pkg.dependencies.docforge = `^${version}`; + pkg.name = path.basename(targetDir); + fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2)); + } + + if (install) { + execSync('npm install', { cwd: targetDir, stdio: 'inherit' }); + } + + console.log(`DocForge starter created at ${targetDir}`); +} + +main(); diff --git a/package.json b/package.json index 8207b88..88375c6 100644 --- a/package.json +++ b/package.json @@ -13,5 +13,8 @@ "lunr": "^2.3.9", "js-yaml": "^4.1.0" }, - "license": "MIT" + "license": "MIT", + "bin": { + "create-docforge": "./bin/create-docforge.js" + } } diff --git a/starter/config.yaml b/starter/config.yaml new file mode 100644 index 0000000..da16234 --- /dev/null +++ b/starter/config.yaml @@ -0,0 +1,6 @@ +site: + title: "DocForge Docs" + description: "Simple static docs." + +navigation: + search: true diff --git a/starter/content/advanced/api/endpoints.md b/starter/content/advanced/api/endpoints.md new file mode 100644 index 0000000..29c88c2 --- /dev/null +++ b/starter/content/advanced/api/endpoints.md @@ -0,0 +1,3 @@ +# API Endpoints + +Document your API here. diff --git a/starter/content/getting-started/01-install.md b/starter/content/getting-started/01-install.md new file mode 100644 index 0000000..7413336 --- /dev/null +++ b/starter/content/getting-started/01-install.md @@ -0,0 +1,3 @@ +# Install + +Run `npm install` then `npm run build` to generate your site. diff --git a/starter/content/getting-started/index.md b/starter/content/getting-started/index.md new file mode 100644 index 0000000..8b9412d --- /dev/null +++ b/starter/content/getting-started/index.md @@ -0,0 +1,3 @@ +# Getting Started + +This section helps you begin with DocForge. diff --git a/starter/content/index.md b/starter/content/index.md new file mode 100644 index 0000000..1f0d723 --- /dev/null +++ b/starter/content/index.md @@ -0,0 +1,3 @@ +# Welcome to DocForge + +This is your new documentation site. Start editing files in the `content/` folder. diff --git a/starter/package.json b/starter/package.json new file mode 100644 index 0000000..842b852 --- /dev/null +++ b/starter/package.json @@ -0,0 +1,11 @@ +{ + "name": "my-docforge-site", + "private": true, + "scripts": { + "dev": "eleventy --serve", + "build": "node node_modules/docforge/src/generator/index.js" + }, + "dependencies": { + "docforge": "*" + } +}