Skip to content

Commit

Permalink
chore: Adding more documentation on how to use this (#6)
Browse files Browse the repository at this point in the history
Co-authored-by: Joey Guerra <[email protected]>
  • Loading branch information
joeyguerra and Joey Guerra authored Oct 14, 2023
1 parent 0657032 commit 81e0926
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,53 @@ This is an example markdown file that utilizes the layouts/index.html layout fil
</html>
```

# Run it

```sh
npx @hubot-friends/sfab --folder ./docs --destination ./_site --verbose
```

# If you install it globally (`npm i @hubot-friends/sfab -g`)

```sh
# builds the site and starts a web server (Express) using a virtual path, e.g. /hubot/. If there's no virtual path (just at the roo), then just `--serve` with no additional value.
sfab --folder ./docs --destination ./_site --verbose --serve /hubot/
```

# Restart when files change (requires Node.js version 20.6.x --watch facility)

```sh
sfab --folder ./docs --destination ./_site --verbose --serve /hubot/ --watch-path ./docs
```

# Hook into the build process

```sh
npx @hubot-friends/sfab --folder ./docs --destination ./_site --verbose --serve /hubot/ --watch-path ./docs --scripts ./sfab-hooks
```

## Example Hook

```javascript
export default () => {
return {
model(file, model) {
// object returned gets Object.assigned to the model passed to the handlebars compiler for use in the templates.
return {
base: {
href: '/hubot/'
}
}
},
async transformed(transformedFilePath) {
// do something during transformation
},
async copied(filePath) {
// file wsa copied to this filePath.
},
async partial(partialName, partial, handebars) {
// partial was registered. passing handlebars if you want to register more.
}
}
}
```
2 changes: 1 addition & 1 deletion sfab.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const registerPartials = async (folder, handlebars, hooks) => {
handlebars.registerPartial(partialName, partial)
for await (let hook of hooks) {
if (!hook?.partial) continue
await hook.partial(partialName, partial)
await hook.partial(partialName, partial, handlebars)
}
}
}
Expand Down

0 comments on commit 81e0926

Please sign in to comment.