Skip to content

Commit

Permalink
fix: Add help command to CLI
Browse files Browse the repository at this point in the history
Also update README, and add warning if using incremental build (as this is not really working for layouts using page getting.
  • Loading branch information
ericselin committed Oct 24, 2021
1 parent 3892365 commit e85c38e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 19 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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.

Expand All @@ -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

Expand Down
23 changes: 22 additions & 1 deletion cmd.ts → cli.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
5 changes: 5 additions & 0 deletions core/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
22 changes: 13 additions & 9 deletions docs/content/index.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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.

Expand All @@ -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

Expand Down

0 comments on commit e85c38e

Please sign in to comment.