Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
antedate
Advanced tools
Readme
Pre-render static websites with ease.
Antedate is a simple API and CLI that uses Chrome pupeteer to pre-render client-side websites. It automatically spins up a local server and renders each route provided.
$ npm install antedate
You can either use the API or CLI.
$ antedate render -r /home -r /about
import antedate from 'antedate'
const routes = ['/', '/about', '/contact'];
const site = './site';
await antedate(site, routes);
// => [
// { html: '....', route: '/', path: '/index.html' },
// { html: '....', route: '/about', path: '/about.html' }
// ...
// ]
await antedate(site, routes, { headless: false, dirs: true });
// => [
// { html: '....', route: '/', path: '/index.html' },
// { html: '....', route: '/about', path: '/about/index.html' }
// ...
// ]
The module also comes with an CLI
Description
Pre-render the routes given
Usage
$ antedate render [options]
Options
-s, --selector Wait for the following selector before rendering
-w, --wait MS to wait before saving page. Happens after selector wait
-r, --route Prerender the route specified
-d, --dir Directory containing the static site (default .)
-o, --output Output directory (default ./static)
-h, --help Displays this message
Examples
$ antedate render -r /home -r /about
Returns: Array
Returns a rendering function that will optionally accept a date
value as its only argument.
Type: String
Required: true
Path to the directory containing the static site to pre-render. Antedate automatically starts a local server.
Type: Array
Required: true
Array of routes to be rendered. The root /
is always rendered last.
E.g. ['/about', '/contact', '/']
.
Type: Object
Required: false
Type: Boolean
Default: false
Wether to run puppeteer in headless mode.
Type: String
Default: ``
Wait for selector
to appear before rendering the site. E.g. body.prerender
.
Type: Number
Default: ``
Milliseconds to before rendering the site.
OBS: This happens after the selector option if both are provided.
Type: Function
Default: ``
A callback function to execute on the page before the rendering happens.
Type: Function
Default: ``
A decorator function that allows you to manupulate the rendered HTML string.
await antedate(site, routes, { decorator: html => html.toUpperCase()});
The idea and logic is based on code from PWA by Luke Edwards. See original implementation in build.js in @pwa/cli.
FAQs
pre-render static websites with ease
The npm package antedate receives a total of 11 weekly downloads. As such, antedate popularity was classified as not popular.
We found that antedate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.