UNPKG

@nera-static/plugin-one-page

Version:

A plugin for Nera static site generator to merge content from multiple markdown pages into single output pages. Perfect for landing pages and one-page layouts.

163 lines (118 loc) โ€ข 3.78 kB
# ๐Ÿ“„ @nera-static/plugin-one-page A plugin for the static site generator [Nera](https://github.com/seebaermichi/nera) to merge content from multiple markdown pages into a single output page. Ideal for landing pages and long-form content. ## โœจ Features - Merge content from multiple `.md` files into one HTML page - Define content order and anchor IDs - Auto-generate anchors from headings if none provided - Optional tag and attribute wrappers per section - Fully configurable via frontmatter and plugin defaults ## ๐Ÿš€ Installation Install the plugin in your Nera project: ```bash npm install @nera-static/plugin-one-page ``` No further setup required โ€” the plugin uses sensible defaults. ## โš™๏ธ Configuration You define behavior directly in the meta section (frontmatter) of your markdown files. By default, the plugin uses the following meta keys: ```yaml add_to_page: <path to main page> add_to_page_order: <sorting order> anchor_id: <custom anchor ID> content_wrapper_tag: <e.g., section, div> content_wrapper_attributes: - attribute: ... value: ... ``` If you'd like to override the default property names, you can create a file `config/one-page.yaml` in your project with custom keys: ```yaml property_name: add_to_page order_property: add_to_page_order anchor_id_property: anchor_id content_wrapper_tag_property: content_wrapper_tag content_wrapper_attributes_property: content_wrapper_attributes ``` ## ๐Ÿงฉ Usage Suppose you want to merge `service.md`, `prices.md`, and `about-us.md` into `index.html`. ### Directory structure ``` pages/ โ”œโ”€โ”€ index.md โ”œโ”€โ”€ service.md โ”œโ”€โ”€ prices.md โ””โ”€โ”€ about-us.md ``` ### Meta frontmatter of sub-pages #### `pages/service.md` ```markdown --- title: Service add_to_page: /index.html add_to_page_order: 1 anchor_id: service-section --- Content for service ``` #### `pages/prices.md` ```markdown --- title: Prices add_to_page: /index.html add_to_page_order: 2 content_wrapper_tag: div content_wrapper_attributes: - attribute: class value: price-wrapper --- Prices content ``` #### `pages/about-us.md` ```markdown --- title: About Us add_to_page: /index.html add_to_page_order: 3 content_wrapper_attributes: - attribute: style value: background-color: red; --- # About Our Company About content goes here. ``` ### What it generates The content of `service.md`, `prices.md`, and `about-us.md` will be appended to the output of `index.html`, wrapped in tags and anchor elements like: ```html <section class="..."> <a id="service-section"></a> Content for service </section> <div class="price-wrapper"> <a id="prices"></a> Prices content </div> <section style="background-color: red;"> <a id="about-our-company"></a> About content goes here. </section> ``` ## ๐Ÿงช Development ```bash npm install npm test npm run lint ``` ### ๐Ÿ”„ Compatibility - **Nera v4.1.0+**: Full compatibility with latest static site generator - **Node.js 18+**: Modern JavaScript features and ES modules - **Plugin Utils v1.1.0+**: Enhanced plugin utilities integration ### ๐Ÿ—๏ธ Architecture This plugin uses the `getMetaData()` function to process page content and merge sections based on frontmatter configuration. It operates purely on content level without requiring templates. ## ๐Ÿง‘โ€๐Ÿ’ป Author Michael Becker [https://github.com/seebaermichi](https://github.com/seebaermichi) ## ๐Ÿ”— Links - [Plugin Repository](https://github.com/seebaermichi/nera-plugin-one-page) - [NPM Package](https://www.npmjs.com/package/@nera-static/plugin-one-page) - [Nera Static Site Generator](https://github.com/seebaermichi/nera) - [Plugin Documentation](https://github.com/seebaermichi/nera#plugins) ## ๐Ÿ“ฆ License MIT