https://github.com/arsfiqball/static-route
Static routing for static website
https://github.com/arsfiqball/static-route
nodejs routing static-site
Last synced: 8 months ago
JSON representation
Static routing for static website
- Host: GitHub
- URL: https://github.com/arsfiqball/static-route
- Owner: Arsfiqball
- Created: 2018-09-09T02:02:40.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-11T13:56:55.000Z (over 7 years ago)
- Last Synced: 2025-05-04T21:16:26.648Z (8 months ago)
- Topics: nodejs, routing, static-site
- Language: JavaScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/Arsfiqball/static-route)
# Installation
```bash
yarn add arsf-static-route
```
# Usage
``staticRoute(mode, callback, options)``
* mode: between ``compile`` to compile pages or ``serve`` to serve pages dynamically.
* callback: a ``function(ctx)``. Context will be passed to manipulate the output pages.
* ``ctx.send(body)`` is the final data which will be sent.
* options: staticRoute options
* ``port`` integer, for server (default: ``3000``)
* ``output`` path string, to compile (default: ``process.cwd() + /dist``)
* ``static`` array of path string (directory), served as static files
* ``clean`` boolean, clean old output before compiling
Example:
```js
const staticRoute = require('arsf-static-route')
staticRoute('serve', router => {
router('/', ctx => ctx.send('Hello World'))
router('/about', ctx => ctx.send('This is about page'))
})
```