open-index/open-npm huggingface dataset:
npm package: @hubot-friends/hubot-templating
Description: Javascript Server side templating engine with string literals
Author: Joey Guerra
Latest version: 1.0.1

# String Literal Templating Engine

## Installation

```sh
npm i @hubot-friends/hubot-templating
```

## Usage

```javascript
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { Template } from '@hubot-friends/hubot-templating'

const __dirname = fileURLToPath(new URL('.', import.meta.url))
const WWW_FOLDER = `${path.resolve(__dirname, './www')}/`

// files like layout files to be leveraged in templates.
const partials = new Map()

// some functions to be used int the templates
const functions = {
    compare: (a, b)=> a == b,
    current: (a, b)=> a.endsWith(b) ? ' current' : '',
    difference: (posts, index)=> posts.length - index - 1,
    format: (date, format)=> date.toLocaleDateString(undefined, format),
    formatTime: (date, format)=> date.toLocaleTimeString(undefined, format),
    formatDate: (date, format)=> date.toLocaleDateString(undefined, format),
}

for await (let file of files){
    let data = await File.readFile(file, 'utf-8')
    let key = file.replace(`${WWW_FOLDER}/`, '').replace(/[\s|\-]/g, '_')
    if(key.indexOf('.html') > -1) {
        partials.set(key, data)
    }
}

const template = new Template('Some text with ${prop.content} in quotes', {prop: content = 'testing content'}, partials, functions)
const text = await template.render()

```

View [index.test.mjs](index.test.mjs) and [test.html](test.html) to see examples on how to create templates.
npm package: @hubot-friends/sfab
Description: Static site generator. From markdown to html with metadata and handlebars.
Author: Joey Guerra
Latest version: 2.0.2

# Static Site Generator

This is a simple static site generator that uses [Express](https://expressjs.com), [markdown](https://github.com/markdown-it/markdown-it), and [Handlebars](https://handlebarsjs.com) to generate a static website.

## Installation

To install the dependencies, run:
`npm i`

## Example building a site

```sh
./
./docs
./docs/index.md
./docs/layouts/
.docs/layouts/index.html
```

**index.md**

```markdown
---
title: Getting Started With sfab
layout: layouts/index.html
published: 2023-10-14T19:25:22.000Z
permalink: /index.html
---

# Getting Started With sfab

This is an example markdown file that utilizes the layouts/index.html layout file.
```

**layouts/index.html**

```html
<!DOCTYPE html>
<html lang="en">
    <head></head>
    <body>
    {{> @partial-block }}
    </body>
</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
```

# Copy another folder to destination

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

## 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(viewKey, transformedFilePath, model, html, viewModel) { // model is the object passed to the temlating engines, viewModel is the object that comes from markdown meta data or html item props.
            // do something during transformation
        },
        async copied(filePath) {
            // file was copied to this filePath.
        },
        async partial(partialName, partial, handebars) {
            // partial was registered. passing handlebars if you want to register more.
        }
    }
}
```

```sh
npm start -- --folder ../../hubotio/hubot/docs --destination ../../hubotio/hubot/_site --verbose --serve /hubot/ --watch-path ../../hubotio/hubot/docs --scripts ../../hubotio/hubot/sfab-hooks
```