{"id":21224201,"url":"https://github.com/admataz/blockstatic","last_synced_at":"2026-05-19T11:06:30.713Z","repository":{"id":3454377,"uuid":"49517528","full_name":"admataz/blockstatic","owner":"admataz","description":"node.js module for generating static HTML","archived":false,"fork":false,"pushed_at":"2022-02-12T15:15:36.000Z","size":151,"stargazers_count":0,"open_issues_count":8,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-26T12:21:19.733Z","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/admataz.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":"2016-01-12T17:39:16.000Z","updated_at":"2020-01-25T11:22:59.000Z","dependencies_parsed_at":"2022-08-06T14:00:52.389Z","dependency_job_id":null,"html_url":"https://github.com/admataz/blockstatic","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admataz%2Fblockstatic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admataz%2Fblockstatic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admataz%2Fblockstatic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admataz%2Fblockstatic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/admataz","download_url":"https://codeload.github.com/admataz/blockstatic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243672369,"owners_count":20328762,"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-20T22:57:21.500Z","updated_at":"2026-05-19T11:06:30.665Z","avatar_url":"https://github.com/admataz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blockstatic HTML content page generator\n\n*Blockstatic* is a collection of utilities that can be used to generate static HTML content pages from Markdown and JSON data files and using Handlebars.js templates. This module can be used alongside other build tasks that look after assets, scripts or styles.\n\n## Installation\n`npm install --save-dev blockstatic`\n\n## Usage\n\nBlockstatic can be used as with a simple command line interface - or as a library in your custom build scripts. \n\nThe most important interfaces are the `buildContentList()` and `buildPages()` which between them allow you to define a directory containing content pages, and with some config options to build HTML output. \n\ne.g.\n\n``` javascript\nblockstatic.buildContentList('./src/content/pagedata', 'https://admataz.com/')\n.then(contentPages =\u003e blockstatic.buildPages(contentPages, './dist', options));\n```\n\nThis will scan the contents of the source path for Markdown and JSON files, and convert each into an HTML page, according to the options passed to it, or defined in the loaded JSON.\n\n\n### 1. Preparing content\n\nIndividual pages can be defined with JSON or as Markdown with YAML front-matter variables\n\n\n- assets:  object with arrays containing assetts for this page.\n- indexPages:  object with list source and ouput options \n- data: object with  each property a path to a json file containing data for the page\n- docs: object with each property a path to a markdown file for rendering in the page\n- routePath: the path to this page\n- meta: key/value pairs for title, author, date, published, and any others like keywords, description etc\n\n\n\n#### JSON\n- `routePath` - the file location (folder) where the output HTML will be written\n- `docs` - a hash of ids and markdown files, which are pulled into the template by key\n- `data` - a hash of ids and JSON files to be used in the handlebars templates, identified in the template by the key\n- `indexPages` - generates a block containing a list of links or pages, as defined by the object\n- `templates` - define a `page` (inner) and `html` (outer) template for each page - paths to `.handlebars` files\n\ne.g. a page definition\n```json\n{\n    \"routePath\": \"about\",\n    \"docs\": {\n        \"page\": \"./sample_content/pages/home.md\",\n        \"about\": \"./sample_content/pages/about.md\"\n    },\n    \"data\": {\n        \"common\": \"./sample_content/data/global-content.json\"\n    },\n    \"indexPages\": {\n         \"articlesIndex\": {\n           \"inputPath\": \"./sample_content/articles\",\n            \"outputPath\": \"articles\", \n            \"limit\": 10\n          }\n     },  \n    \"templates\": {\n        \"page\": \"./sample_content/templates/page_home.handlebars\",\n        \"html\": \"./sample_content/templates/html.handlebars\"\n    },\n    \"meta\": {\n      \"title\": \"admataz. ideas + code\",\n      \"author\": \"Adam Davis\",\n      \"date\": \"2019-10-07\",\n      \"description\": \"admataz\",\n      \"keywords\": \"code, adam davis, web\",\n      \"published\": true\n    }\n\n}\n```\n\n#### Markdown with front-matter\nThe markdown parser supports standard Markdown with a YAML front-matter:\n\nNote for markdown the `routePath` `docs` `data` `indexPages` `templates` `assets` are extracted, and what remains is `meta`\n\n\n```yaml\n---\nauthor: Adam Davis  \ndate: 2012-01-16  \ndescription: \"Some thoughts on code, beauty and art: my response to a request from a journalist.\"\nkeywords: code, beauty, art, opinion,  \ntitle: code, beauty and art.\npublished: true\nindexPages: \n    listIndex:\n        inputPath: \"./src/content/code-ideas\"\n        outputPath: \"/code-ideas\"\n        limit: 10\nassets: \n  js: \n    - ./src/scripts/funky.js\n---\n```\n\n\n\nThat should get you started.\n\n\n### Example\n\nIn the example below I am generating pages for my website.\n\n```js\n\nconst config = {\n   templates: {\n    html: \"./src/templates/html.handlebars\",\n    page: \"./src/templates/page.handlebars\"\n  },\n  site: {\n    title: \"admataz - code and javascript\",\n    homePageUrl: \"http://admataz.com\",\n    feedUrl: \"http://admataz.com/feed.json\",\n    description: \"Site for admataz\",\n    itemRoot: \"http://admataz.com/\"\n  }\n    baseUrl: 'https://admataz.com'\n  }\n\nlet compiledContent\nblockstatic.buildContentList('./src/pages', 'https://admataz.com', 0)\n.then(contentList =\u003e blockstatic.buildPages(contentList, './dist', config ))\n.then(contentPages =\u003e await Promise.all(contentPages))\n.then(compcontent =\u003e {\n  compiledContent = compcontent\n  return blockstatic.jsonFeedTemplate(\n    compiledContent,\n    options.site\n  )\n  }\n  )\n.then(jsonFeed =\u003e jf.writeFile(`${dest}/index.json`, jsonFeed))\n.then(() =\u003e {\n  return blockstatic.rssFeedTemplate(\n    compiledContent,\n    options.site\n  )\n  }\n  )\n  .then(rssFeed =\u003e fs.writeFile(`${dest}/index.xml`, rssFeed, 'utf8'))\n  .catch(err =\u003e console.log(err))\n\n```\n\n### Command-line\n\nYou can integrate this basic interface into your npm scripts or other build tools: \n\n```\nOptions:\n  -V, --version        output the version number\n  -c, --config \u003cpath\u003e  JSON input for default values (site details, templates for html and page required)\n  -s, --src \u003cpath\u003e     Source content folder (.md and .json)\n  -u, --baseurl \u003curl\u003e  Base url for the generated html\n  -o, --output \u003cpath\u003e  Output dir path\n  -h, --help           output usage information\n```\n\n\n### Tests\nI started writing some - these need completing.\n\n\n\n### License\nThe MIT License (MIT)\nCopyright (c) 2019 Adam Davis\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadmataz%2Fblockstatic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadmataz%2Fblockstatic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadmataz%2Fblockstatic/lists"}