{"id":18426388,"url":"https://github.com/complate/complate-ssg","last_synced_at":"2025-04-13T18:54:21.292Z","repository":{"id":57204668,"uuid":"94550342","full_name":"complate/complate-ssg","owner":"complate","description":"static-site generator for complate","archived":false,"fork":false,"pushed_at":"2019-12-11T08:32:30.000Z","size":28,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T21:16:26.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/complate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-16T14:11:36.000Z","updated_at":"2019-12-11T08:32:25.000Z","dependencies_parsed_at":"2022-09-18T01:00:54.964Z","dependency_job_id":null,"html_url":"https://github.com/complate/complate-ssg","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complate%2Fcomplate-ssg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complate%2Fcomplate-ssg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complate%2Fcomplate-ssg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/complate%2Fcomplate-ssg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/complate","download_url":"https://codeload.github.com/complate/complate-ssg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248766304,"owners_count":21158297,"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":[],"created_at":"2024-11-06T05:07:49.497Z","updated_at":"2025-04-13T18:54:21.263Z","avatar_url":"https://github.com/complate.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"complate-ssg\n============\n\nstatic-site generator for [complate](https://complate.org), creating HTML pages\nfrom Markdown and other formats\n\n[![package version](https://img.shields.io/npm/v/complate-ssg.svg?style=flat)](https://www.npmjs.com/package/complate-ssg)\n[![build status](https://travis-ci.org/complate/complate-stream.svg?branch=master)](https://travis-ci.org/complate/complate-ssg)\n[![Greenkeeper badge](https://badges.greenkeeper.io/complate/complate-ssg.svg)](https://greenkeeper.io)\n\n\nGetting Started\n---------------\n\n```\n$ npm install complate-ssg\n```\n\n```\n$ complate-ssg [options] [content_directory [target_directory]]\n```\n\n(See `complate-ssh -h` for a list of options.)\n\nSource files (see [Source Content](#source-content) below) reside in the content\ndirectory, resulting HTML files will be created in the target directory.\n\nThe easiest way is to start from the samples (e.g. by copying\n`node_modules/complate-ssg/samples`):\n\n* complate is used to generate a views bundle for rendering HTML – typically\n  with [faucet-pipeline](http://faucet-pipeline.org) compiling JSX\n* complate-ssg uses these views to generate HTML pages from Markdown files\n\n\nSource Content\n--------------\n\nOut of the box, complate-ssg treats `.md` files as\n[Markdown](http://commonmark.org/help/). For additional formats, see\n[Customization](#customization) below.\n\nEach file must contain a metadata preamble (AKA front matter) at the top,\nseparated by a blank line:\n\n```markdown\ntitle: Hello World\n\nlorem ipsum\n\n* foo\n* bar\n\ndolor sit amet\n```\n\n\nViews\n-----\n\nHTML is rendered using complate views:\n\n```jsx\nfunction render({ slug, metadata, html }) {\n    return \u003cDefaultLayout title={meta.title}\u003e\n        {safe(html)}\n    \u003c/DefaultLayout\u003e;\n}\n\nfunction DefaultLayout({ title }, ...children) {\n    return \u003chtml\u003e\n        \u003chead\u003e\n            \u003cmeta charset=\"utf-8\" /\u003e\n            \u003ctitle\u003e{title}\u003c/title\u003e\n        \u003c/head\u003e\n\n        \u003cbody\u003e\n            {children}\n        \u003c/body\u003e\n    \u003c/html\u003e;\n}\n```\n\nThe `render` function serves as the entry point for all pages; it might render\ndifferent layouts based on `slug`, which is passed in alongside source contents'\n`metadata` and `html`.\n\nNext we need to register that `render` function and allow complate-ssg to invoke\nit via `renderView`:\n\n```jsx\nimport Renderer, { createElement, safe } from \"complate-stream\";\n\nlet { registerView, renderView } = new Renderer();\n\nregisterView(render);\n\nexport default renderView;\n```\n\nFinally, we need to compile our JSX views to a bundle (`dist/views.js` by\ndefault), e.g. using [faucet-pipeline](http://faucet-pipeline.org) – see the\n`samples` directory for details.\n\n\nCustomization\n-------------\n\nRendering of source content can be customized via the imperative API – e.g. for\nadditional file extensions, formats or to adjust link URIs.\n\nLet's create a file `ssg.js`:\n\n```javascript\nlet ssg = require(\"complate-ssg\");\nlet markdown = require(\"complate-ssg/src/markdown\");\n\n// all arguments are optional; defaults are shown below\nlet referenceDir = __dirname;\nlet options = { // all entries are optional\n    transforms: {\n        md: (source, metadata) =\u003e markdown(source)\n    }\n};\nssg(referenceDir, options);\n```\n\nThe built-in Markdown module supports influencing link targets, e.g. to remove\nthe `.html` file extension for internal links:\n\n```javascript\noptions.transforms = {\n    html: (source, metadata, pages) =\u003e markdown(source, {\n        resolveURI: uri =\u003e {\n            if(pages.has(uri)) {\n                return uri.replace(\".html\", \"\");\n            }\n            return uri;\n        }\n    })\n};\n```\n\nIf we want to support a different file extension, we need to add an entry to\n`options.transforms`:\n\n```javascript\noptions.transforms = {\n    txt: (source, metadata) =\u003e source\n};\n```\n\nThis will add support for `.txt` files in the content directory, passing\ncontents through unmodified. (Note that these files also require a metadata\npreamble, even though it's unused here.)\n\nWe might also want to support other formats, e.g.\n[AsciiDoc](https://asciidoctor.org) – in which case we'd have to find some\nlibrary to generate HTML from `.adoc` sources:\n\n```javascript\noptions.transforms = {\n    adoc: (source, metadata) =\u003e asciidoc(source, { layout: metadata.layout })\n};\n```\n\nHere's an approximation of complate-ssg's default values for reference:\n\n```javascript\nlet referenceDir = process.cwd();\nlet options = {\n    content: \"./content\",\n    target: \"./dist/site\",\n    views: {\n        bundle: \"./dist/views.js\",\n        name: \"render\"\n    },\n    transforms: {\n        md: (source, metadata) =\u003e markdown(source, {\n            // if true, this activates typographic enhancements like smart\n            // quotes, dashes and ellipses\n            smart: metadata.smart,\n            // if true, this disallows raw HTML in Markdown sources\n            safe: metadata.safe\n        })\n    }\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomplate%2Fcomplate-ssg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomplate%2Fcomplate-ssg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomplate%2Fcomplate-ssg/lists"}