diff --git a/README.md b/README.md index 8d84e47..cc040bc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Bob the static site builder +# bob the static site builder -Bob is a static site generator built on top of the [Deno](https://deno.land) runtime. +`bob` is a static site generator built on top of the [Deno](https://deno.land) runtime. ## Features @@ -25,12 +25,10 @@ Bob is designed for creating extremely performant websites that require near-ins ### 🤓 Best-in-class developer experience -- Fully typed using TypeScript +- Fully typed using TypeScript and TSX Intellisense and type checking in layout templates. - Highly modular - Everything is a module internally, increasing customizability and maintainability. -- Structure your layouts any way you like - The only thing that is needed is a function that takes a content page and renders it into HTML. The rest is up to you. Use template literals, JSX (example coming soon), or any other way to make this happen. + Layouts are just TSX components. Import any additional components or libraries as you wish. - Easily create client-side components (coming soon) Create client-side code right in your layout files. @@ -39,16 +37,22 @@ Bob is designed for creating extremely performant websites that require near-ins You need to have the [Deno](https://deno.land) runtime installed. When you have it installed, just run: ``` -deno install -A [PATH TO CMD.TS] +deno install --allow-read --allow-write --allow-net https://deno.land/x/bob/cli.ts ``` ## Usage -See the `demo` directory for an example implementation. +To build your site, in the site root, just run: + +``` +$> bob +``` + +See the `docs` directory for an example implementation. See CLI help with `bob -h`. ### Layout files -Structure your layout files as you wish, and export a renderer function from a file named `site.ts`. This function will be called with a `ContentFile` for each content page that should be rendered. +Layouts are just TSX components, exported as a default export from different files. Structure your code and components as you wish, but make sure you have a default layout located in `layouts/_default.tsx`. ### Content files diff --git a/cmd.ts b/cli.ts similarity index 50% rename from cmd.ts rename to cli.ts index a4c8913..2a9aac7 100644 --- a/cmd.ts +++ b/cli.ts @@ -1,7 +1,28 @@ import { build } from "./mod.ts"; import { log, parseFlags } from "./deps.ts"; -const { v: verbose, f: force } = parseFlags(Deno.args); +const usage = `bob the static site builder + +Build the content files in the \`content\` directory, +using the TSX layouts in the \`layouts\` directory, +into the output directory \`public\`. + +Builds are by default incremental, i.e. build only +what is needed. + +OPTIONS: + +-f force build everything + will clean the current public directory +-v verbose logging +-h show help`; + +const { v: verbose, f: force, h: help } = parseFlags(Deno.args); + +if (help) { + console.log(usage); + Deno.exit(); +} const logLevel = verbose ? "DEBUG" : "INFO"; diff --git a/core/api.ts b/core/api.ts index d4b0fe3..d8a2792 100644 --- a/core/api.ts +++ b/core/api.ts @@ -77,6 +77,11 @@ export const build: Builder = async (options) => { `Build directories: content:${contentDir} layouts:${layoutDir} public:${publicDir}`, ); + if (!force) { + log?.warning("Incremental builds are currently experimental"); + log?.warning("Use `-f` CLI flag to force build everything"); + } + if (force && await exists(publicDir)) { log?.warning(`Cleaning public directory ${publicDir}`); await Deno.remove(publicDir, { recursive: true }); diff --git a/docs/content/index.md b/docs/content/index.md index 8d84e47..cc040bc 100644 --- a/docs/content/index.md +++ b/docs/content/index.md @@ -1,6 +1,6 @@ -# Bob the static site builder +# bob the static site builder -Bob is a static site generator built on top of the [Deno](https://deno.land) runtime. +`bob` is a static site generator built on top of the [Deno](https://deno.land) runtime. ## Features @@ -25,12 +25,10 @@ Bob is designed for creating extremely performant websites that require near-ins ### 🤓 Best-in-class developer experience -- Fully typed using TypeScript +- Fully typed using TypeScript and TSX Intellisense and type checking in layout templates. - Highly modular - Everything is a module internally, increasing customizability and maintainability. -- Structure your layouts any way you like - The only thing that is needed is a function that takes a content page and renders it into HTML. The rest is up to you. Use template literals, JSX (example coming soon), or any other way to make this happen. + Layouts are just TSX components. Import any additional components or libraries as you wish. - Easily create client-side components (coming soon) Create client-side code right in your layout files. @@ -39,16 +37,22 @@ Bob is designed for creating extremely performant websites that require near-ins You need to have the [Deno](https://deno.land) runtime installed. When you have it installed, just run: ``` -deno install -A [PATH TO CMD.TS] +deno install --allow-read --allow-write --allow-net https://deno.land/x/bob/cli.ts ``` ## Usage -See the `demo` directory for an example implementation. +To build your site, in the site root, just run: + +``` +$> bob +``` + +See the `docs` directory for an example implementation. See CLI help with `bob -h`. ### Layout files -Structure your layout files as you wish, and export a renderer function from a file named `site.ts`. This function will be called with a `ContentFile` for each content page that should be rendered. +Layouts are just TSX components, exported as a default export from different files. Structure your code and components as you wish, but make sure you have a default layout located in `layouts/_default.tsx`. ### Content files