{"id":23773650,"url":"https://github.com/beenotung/node-data-template","last_synced_at":"2026-05-08T04:48:08.589Z","repository":{"id":190188299,"uuid":"681883398","full_name":"beenotung/node-data-template","owner":"beenotung","description":"Fast, SEO-friendly server-side rendering (SSR) data-template for smoother user experiences","archived":false,"fork":false,"pushed_at":"2023-12-06T18:47:03.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-02T07:41:18.690Z","etag":null,"topics":["agnostic","data-template","engine","express","html","seo","server-rendering","server-side-rendering","ssr","template","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/node-data-template","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beenotung.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-23T01:11:20.000Z","updated_at":"2023-09-11T18:59:17.000Z","dependencies_parsed_at":"2023-12-06T19:45:44.380Z","dependency_job_id":null,"html_url":"https://github.com/beenotung/node-data-template","commit_stats":null,"previous_names":["beenotung/node-data-template"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/beenotung/node-data-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fnode-data-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fnode-data-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fnode-data-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fnode-data-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beenotung","download_url":"https://codeload.github.com/beenotung/node-data-template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fnode-data-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32767591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T02:36:36.067Z","status":"ssl_error","status_checked_at":"2026-05-08T02:36:07.210Z","response_time":54,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["agnostic","data-template","engine","express","html","seo","server-rendering","server-side-rendering","ssr","template","typescript"],"created_at":"2025-01-01T05:41:45.687Z","updated_at":"2026-05-08T04:48:08.570Z","avatar_url":"https://github.com/beenotung.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-data-template\n\n[![npm Package Version](https://img.shields.io/npm/v/node-data-template)](https://www.npmjs.com/package/node-data-template)\n\nFast, SEO-friendly server-side rendering (SSR) [data-template](https://github.com/beenotung/data-template) for smoother user experiences.\n\nnode-data-template is framework agnostic (with express support).\n\n## Motivation\n\nServer-side rendering (SSR) pages with data-template into plain HTML to deliver information as soon as possible. Directly delivery content over the wire (without running any javascript and ajax on the client side) enhances user experience by presenting readable content immediately upon request, reducing wait times and potential user frustration.\n\nThe benefits of SSR extend beyond speed; it also improves Search Engine Optimization (SEO). Search engine crawlers often have lower priority to run and index JavaScript-rendered content, but they can readily understand and index server-rendered HTML. This means your website's content is more likely to appear in search results, driving more organic traffic to your site.\n\nIn summary, server-side rendering is a effective strategy for boosting both the speed and SEO performance of a website.\n\n## Installation\n\n```bash\nnpm install node-data-template\n```\n\nYou can also install it with [pnpm](https://pnpm.io), [yarn](https://yarnpkg.com), or [slnpm](https://github.com/beenotung/slnpm)\n\n## Usage Examples\n\nA complete example can be found in [example/server.ts](./example/server.ts)\n\n```typescript\nimport express from 'express'\nimport { dataTemplate, scanTemplates } from 'node-data-template'\n\nlet templates = dataTemplate({\n  templateDir: 'public',\n  minify: true,\n})\n\nlet app = express()\n\nlet articles = [\n  /*...*/\n]\n\napp.get('/articles', (req, res) =\u003e res.json({ articles }))\n\napp.get(\n  '/',\n  templates.handle((context, req, next) =\u003e {\n    scanTemplates(context, context.document, { articles })\n  }),\n)\n\napp.use(express.static('public'))\n\napp.listen(8100, () =\u003e {\n  console.log('Server started and listening at http://localhost:8100')\n})\n```\n\n## API Types\n\n**Express Middleware Creator**:\n\n```typescript\nfunction dataTemplate(options: {\n  templateDir: string\n  minify?: boolean\n}): DataTemplateHandler\n\ninterface DataTemplateHandler {\n  // to be used in express route handler\n  handle: (render: RenderFn) =\u003e RequestHandler\n}\n\ntype RenderFn = (\n  context: DataTemplateContext,\n  req: Request,\n  next: NextFunction,\n) =\u003e void | Promise\u003cvoid\u003e\n```\n\n**Core Functions**:\n\n```typescript\ntype DataTemplateContext = {\n  document: Document\n  templateDir: string\n}\nfunction loadDocument(templateDir: string, filename: string): Document\nfunction renderTemplate(\n  context: DataTemplateContext,\n  host: HTMLElement,\n  binds?: {},\n): void\nfunction scanTemplates(\n  context: DataTemplateContext,\n  root?: Document,\n  binds?: {},\n): void\nfunction fillForm(form: HTMLElement, o: object): void\nfunction d2(x: number): string | number\nfunction toInputDate(date: string | number | Date): string\nfunction toInputTime(date: string | number | Date): string\nfunction renderData(container: Node, values: object): void\n```\n\nWhere the `Document` is a shim from the lightweight library `html-parser.ts` with `outerHTML` and `minifiedOuterHTML`.\n\n## License\n\nThis project is licensed with [BSD-2-Clause](./LICENSE)\n\nThis is free, libre, and open-source software. It comes down to four essential freedoms [[ref]](https://seirdy.one/2021/01/27/whatsapp-and-the-domestication-of-users.html#fnref:2):\n\n- The freedom to run the program as you wish, for any purpose\n- The freedom to study how the program works, and change it so it does your computing as you wish\n- The freedom to redistribute copies so you can help others\n- The freedom to distribute copies of your modified versions to others\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeenotung%2Fnode-data-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeenotung%2Fnode-data-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeenotung%2Fnode-data-template/lists"}