You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
webpack-plugin/README.md

240 lines
4.9 KiB

# Site-O-Mat Webpack Plugin
1 year ago
A Webpack Plugin for generating a Website as Html-Files from a Markdown-File Structure.
1 year ago
Why? The Main reason i had to update some Websites, but realize there were no benefit
to use a Full CMS or Headless CMS like Directus. Rendering the same pages that a rarely updated
seems like a waste of energy. Why not generate from a hierarchical file structure. Luckily i
i had development a CMS, a few years ago, that runs on Markdown Files it had been never
finished, it was a proof of concept.
1 year ago
1 year ago
## Roadmap
Next will be,
* Some Tests
* Filtering for Queries
* Standalone, handle Webpack only as wrapper
1 year ago
Maybe later,
1 year ago
* Integrate Eta.js and LiquidJS
* Hooks for handle generic content
1 year ago
1 year ago
## Installation
1 year ago
Setup this registry in your project .npmrc file:
```
@helpers:registry=https://gitea.node001.net/api/packages/HerrHase/npm/
```
Install with npm or yarn
1 year ago
```
1 year ago
npm i --save-dev @helpers/siteomat-webpack-plugin
yarn add --dev @helpers/siteomat-webpack-plugin
1 year ago
```
## Configuration
Basic Usage:
1 year ago
```
const SiteomatWebpackPlugin = require('siteomat-webpack-plugin')
1 year ago
plugins: [
new SiteomatWebpackPlugin(
1 year ago
'./resources/site',
'./resources/views'
)
]
1 year ago
```
Add options:
1 year ago
```
plugins: [
new SiteomatWebpackPlugin(
'./resources/site',
'./resources/views',
{
<options>
}
)
]
```
1 year ago
| Name | Type | Default | Description |
|-------------|-----------|---------|-------------|
| destination | {String} | null | If not set, it will use the public path |
| htmlMinify | {Boolean} | true | Minify Html and remove all Whitespace |
## Pages
1 year ago
Pages are Markdown-Files, they are separates in two parts. First part is a yaml-Section,
1 year ago
1 year ago
```
---
title: "health goth DIY tattooed"
view: "home.njk"
meta:
description: "La"
media:
teaser:
src: "_images/test.jpeg"
alt: "cold-pressed"
---
```
The yaml-Section will be parsed as an Object and available in the Templates. The
second part of the File will be parsed as Markdown, but it could be also empty.
1 year ago
1 year ago
Default type for Pages is **html**.
1 year ago
1 year ago
## Nesting
A Page can be a single Markdown-File, or a Directory with a index-File inside.
The Name of a file or a directory will the name of the html-File. To create Sub-pages,
create Sub-directories.
This Structure,
1 year ago
```
index.md
1 year ago
about-me.md
1 year ago
blog
1 year ago
└ index.md
1 year ago
belly-polaroid-subway.md
```
will be,
1 year ago
```
index.html
about-me.html
blog.html
blog/belly-polaroid-subway.html
1 year ago
```
## Blocks
Each Page can have Blocks. Blocks are like Pages, but they are only accessible
for a single Page. To add Blocks to a page, add a "_blocks"-Directory
to the Directory of the Page.
Markdown-Files in a "_blocks"-Directory will be automatic accessible for a Page. The yaml-Section is Optional.
```
recipes
└ index.md
_blocks
└ hero-1.md
hero-2.md
hero-3.md
```
1 year ago
Blocks will be Grouped by there name, and sorted by the number at the end. The "hero"-Files
can be used like this,
1 year ago
```
{% hero in page.blocks.hero %}
{{ hero.content }}
{% endFor %}
```
1 year ago
## Queries
1 year ago
Queries can be used in Templates to get Pages.
1 year ago
### Pages
1 year ago
Basic Usage:
```
pageQuery.find()
```
or with options,
| Name | Type | Default | Description |
|-------------|-----------|---------|-------------|
1 year ago
| parent | {String} | / | Directory for start query |
| deep | {Integer} | -1 | Deep of Recursive |
| orderBy | {Array} | null | Name of field sorting, a "-" in front of the. Nested fields are also possible. |
1 year ago
| limit | {Integer} | null | Limit results |
| filter | {Object} | null | Filtering results by Fields in yaml |
#### Filter
Basic Usage:
```
{
<fieldname>: {
<operator>: <value>
}
}
```
| Name | Description |
|-------------|-------------|
| _eq | Equal Value |
1 year ago
## Sitemap
Sitemap will be generating by Pages. Pages will be only add to Sitemap, if the have meta-robots is set
to "index". Pages default is "index".
## Templates
At this Time only [https://mozilla.github.io/nunjucks/](Nunjunks) is used for Templating.
### Nunjunks
1 year ago
#### Functions
##### asset(path)
This function handle manifest-File from [https://laravel-mix.com/](Laravel-Mix).
```
<script src="{{ asset('js/app.js') }}"></script>
```
#### Filters
##### resize
The Filter is using [https://github.com/lovell/sharp](sharp), for crop, resize and
optimize Images. The Filter needs a relative Path in the File Structure.
Basic Usage:
```
{% page.teaser.src | resize({ 'width': '300' }) %}
```
Add options:
```
{% page.teaser.src | resize({ 'width': '300' }, { sigma: 2 }) %}
1 year ago
```
1 year ago
## Json
Results from PageQuery can also be created as json-File. The can use with a
simple API [https://gitea.node001.net/HerrHase/siteomat-api](https://gitea.node001.net/HerrHase/siteomat-api). Create a
1 year ago
File "json.yml" and add options.
1 year ago
Basic Usage:
```
posts:
orderBy:
- '-date_published'
filter:
view:
_eq: 'post.njk'
1 year ago
```