{"id":13826069,"url":"https://github.com/terkelg/antedate","last_synced_at":"2025-04-09T18:35:24.297Z","repository":{"id":57180681,"uuid":"191470713","full_name":"terkelg/antedate","owner":"terkelg","description":"A tiny pre-renderer for client side applications.","archived":false,"fork":false,"pushed_at":"2019-08-22T15:00:11.000Z","size":17,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T20:37:17.998Z","etag":null,"topics":["chrome","optimization","prerender","puppeteer","seo-optimization","static-site","static-site-generator"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terkelg.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-12T00:47:49.000Z","updated_at":"2025-02-19T18:35:27.000Z","dependencies_parsed_at":"2022-09-14T03:40:32.300Z","dependency_job_id":null,"html_url":"https://github.com/terkelg/antedate","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terkelg%2Fantedate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terkelg%2Fantedate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terkelg%2Fantedate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terkelg%2Fantedate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terkelg","download_url":"https://codeload.github.com/terkelg/antedate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247941702,"owners_count":21022038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome","optimization","prerender","puppeteer","seo-optimization","static-site","static-site-generator"],"created_at":"2024-08-04T09:01:31.682Z","updated_at":"2025-04-09T18:35:24.266Z","avatar_url":"https://github.com/terkelg.png","language":"JavaScript","readme":"# Antedate\n\n\u003e Pre-render static websites with ease.\n\nAntedate is a simple API and CLI that uses Chrome pupeteer to pre-render client-side websites.\nIt automatically spins up a local server and renders each route provided.\n\n## Install\n\n```\n$ npm install antedate\n```\n\n\n## Usage\n\nYou can either use the [API](#api) or [CLI](#cli).\n\n```\n$ antedate render -r /home -r /about\n```\n\n```js\nimport antedate from 'antedate'\n\nconst routes = ['/', '/about', '/contact'];\nconst site = './site';\n\nawait antedate(site, routes);\n// =\u003e [\n//      { html: '....', route: '/', path: '/index.html' },\n//      { html: '....', route: '/about', path: '/about.html' }\n//      ...\n// ]\n\nawait antedate(site, routes, { headless: false, dirs: true });\n// =\u003e [\n//      { html: '....', route: '/', path: '/index.html' },\n//      { html: '....', route: '/about', path: '/about/index.html' }\n//      ...\n// ]\n```\n\n\n## CLI\n\nThe module also comes with an CLI \n\n```\n  Description\n    Pre-render the routes given\n\n  Usage\n    $ antedate render [options]\n\n  Options\n    -s, --selector    Wait for the following selector before rendering\n    -w, --wait        MS to wait before saving page. Happens after selector wait\n    -r, --route       Prerender the route specified\n    -d, --dir         Directory containing the static site  (default .)\n    -o, --output      Output directory  (default ./static)\n    -h, --help        Displays this message\n\n  Examples\n    $ antedate render -r /home -r /about\n```\n\n\n## API\n\n### antedate(root, routes, opts?)\nReturns: `Array`\n\nReturns a rendering function that will optionally accept a [`date`](#date) value as its only argument.\n\n#### root\nType: `String`\u003cbr\u003e\nRequired: `true`\n\nPath to the directory containing the static site to pre-render. Antedate automatically starts a local server.\n\n#### routes\nType: `Array`\u003cbr\u003e\nRequired: `true`\n\nArray of routes to be rendered. The root `/` is always rendered last.\nE.g. `['/about', '/contact', '/']`.\n\n#### opts\nType: `Object`\u003cbr\u003e\nRequired: `false`\n\n##### headless\nType: `Boolean`\u003cbr\u003e\nDefault: `false`\n\nWether to run puppeteer in headless mode.\n\n##### selector\nType: `String`\u003cbr\u003e\nDefault: ``\n\nWait for `selector` to appear before rendering the site. E.g. `body.prerender`.\n\n##### wait\nType: `Number`\u003cbr\u003e\nDefault: ``\n\nMilliseconds to before rendering the site. \n\u003e **OBS:** This happens after the [selector](#selector) option if both are provided.\n\n##### script\nType: `Function`\u003cbr\u003e\nDefault: ``\n\nA callback function to execute on the page before the rendering happens. \n\n##### decorator\nType: `Function`\u003cbr\u003e\nDefault: ``\n\nA decorator function that allows you to manupulate the rendered HTML string.\n\n```js\nawait antedate(site, routes, { decorator: html =\u003e html.toUpperCase()});\n```\n\n\n## Credit\n\nThe idea and logic is based on code from [PWA](https://github.com/lukeed/pwa) by [Luke Edwards](https://github.com/lukeed). See original implementation in [build.js](https://github.com/lukeed/pwa/blob/master/packages/cli/lib/build.js#L114) in [@pwa/cli](https://github.com/lukeed/pwa/blob/master/packages/cli).\n\n\n## License\n\n[MIT License](LICENSE) @ [Terkel Gjervig](https://terkel.com)","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterkelg%2Fantedate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterkelg%2Fantedate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterkelg%2Fantedate/lists"}