mirror of
https://github.com/sigmasternchen/grimoire
synced 2025-03-15 08:08:55 +00:00
Compare commits
7 commits
04dadfa8e4
...
7fe6ce3d29
Author | SHA1 | Date | |
---|---|---|---|
7fe6ce3d29 | |||
6df6c0b20b | |||
a31797a950 | |||
01059c05b6 | |||
7156638cbc | |||
9323d78c37 | |||
5b06ef0ec1 |
5 changed files with 189 additions and 6 deletions
32
.github/workflows/release.yml
vendored
Normal file
32
.github/workflows/release.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: [ "*" ]
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: 3.11
|
||||
- name: Set up Poetry
|
||||
run: |
|
||||
python -m pip install poetry
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
poetry install
|
||||
- name: Build
|
||||
run: |
|
||||
poetry build
|
||||
- name: Mint token
|
||||
id: mint
|
||||
uses: tschm/token-mint-action@v1.0.2
|
||||
- name: Publish
|
||||
run: |
|
||||
poetry publish -u __token__ -p '${{ steps.mint.outputs.api-token}}'
|
147
README.md
Normal file
147
README.md
Normal file
|
@ -0,0 +1,147 @@
|
|||
# Grimoire SSG
|
||||
|
||||
Grimoire is a minimalistic Static Site Generator (SSG) designed to simplify the process of
|
||||
creating static websites. With Grimoire, most use cases can be addressed without the need
|
||||
for programming knowledge — simply modify YAML files to generate your site.
|
||||
|
||||
## Features
|
||||
|
||||
- **YAML Configuration**: Define your content and structure using simple YAML files.
|
||||
- **Template Rendering**: Utilize Jinja2 templates for dynamic content generation.
|
||||
- **Markdown Support**: Write content in Markdown, which is automatically converted to HTML.
|
||||
- **Tagging System**: Organize your content with tags for easy referencing in templates.
|
||||
- **File Inclusion**: Include other YAML files to create a modular content structure.
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Installation & Usage
|
||||
|
||||
To get started with Grimoire, you can directly install it using pip:
|
||||
|
||||
```bash
|
||||
pip install grimoire-ssg
|
||||
```
|
||||
|
||||
To generate your static site, run the Grimoire command with your input YAML files.
|
||||
You can specify an output directory using the `-o` or `--output` flag.
|
||||
|
||||
```bash
|
||||
python -m grimoire-ssg -o output_directory one_or_more_input_files.yml
|
||||
```
|
||||
|
||||
### Alternative Installation
|
||||
|
||||
Alternatively, you can clone the repository and install the
|
||||
required dependencies with [Poetry](https://python-poetry.org/):
|
||||
|
||||
```bash
|
||||
git clone https://github.com/sigmasternchen/grimoire-ssg.git
|
||||
cd grimoire-ssg
|
||||
poetry install
|
||||
```
|
||||
|
||||
You can then run the program directly using Poetry:
|
||||
|
||||
```bash
|
||||
poetry run python -m grimoire-ssg -o output_directory one_or_more_input_files.yml
|
||||
```
|
||||
|
||||
### Example YAML File
|
||||
|
||||
Here is an example of a YAML file that defines a content structure:
|
||||
|
||||
```yaml
|
||||
# (optional) Included files will also be considered for generation.
|
||||
# If this attribute is missing or empty, no other files will be included.
|
||||
include:
|
||||
- pages/*.yml
|
||||
- blog/*.yml
|
||||
|
||||
# (optional) List of tags for this file.
|
||||
# These can be used in templates later to reference this content.
|
||||
# If this attribute is missing or empty, this file will not be accessible
|
||||
# via any tags.
|
||||
tags:
|
||||
- page
|
||||
|
||||
# (optional) The file that should be generated from this .yml file.
|
||||
# If this attribute is missing, no output file will be generated.
|
||||
output: index.html
|
||||
|
||||
# (optional) Path to the template for this .yml file.
|
||||
# If this attribute is missing, no output will be generated.
|
||||
# It's also possible to just use `template` without `output`. In that case
|
||||
# the rendered template can still be accessed by other templates.
|
||||
template: ../templates/homepage.html
|
||||
|
||||
# (optional) The markdown content for this output file.
|
||||
# If this attribute is missing, the markdown content can not be
|
||||
# referenced by the template.
|
||||
markdown: |
|
||||
# Hello, World!
|
||||
|
||||
# All other defined attributes are not interpreted by the program, but
|
||||
# can still be referenced by a template.
|
||||
# The following are some examples:
|
||||
Date: 2025-01-06
|
||||
Author: Sigma
|
||||
```
|
||||
|
||||
### Template Example
|
||||
|
||||
Grimoire uses Jinja2 templates for rendering. Below is an example of a template that
|
||||
extends a layout and includes dynamic content:
|
||||
|
||||
```jinja
|
||||
{% extends template_dir + "/layout.templ.html" %}
|
||||
{% block title %}Homepage{% endblock %}
|
||||
{% block content %}
|
||||
{{ current.markdown_compiled | safe }}
|
||||
|
||||
<h2>My latest blog articles:</h2>
|
||||
<ul>
|
||||
{% for entry in tags["blog"] %}
|
||||
<li><a href="{{ entry.output }}">{{ entry.title }}</a> ({{ entry.date }})</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
```
|
||||
|
||||
### Template Parameters
|
||||
|
||||
The following parameters are available in your templates:
|
||||
|
||||
- `current`: The current content file being rendered.
|
||||
- `all`: A list of all content files.
|
||||
- `tags`: A dictionary of tags with corresponding content files.
|
||||
- `template_dir`: The absolute path to the parent directory of the current template.
|
||||
|
||||
The content file objects in the template contain all fields from the corresponding YAML file.
|
||||
Additionally, the following fields are defined:
|
||||
- `filename` is the absolute filename of the yml file.
|
||||
- `relative_filename` is the filename of the yml file relative to the working directory.
|
||||
- `markdown_compiled` is the compiled markdown content in HTML form. In combination with the `safe` filter in Jinja2 the markdown content can be output.
|
||||
- `rendered` is the rendered template of that file. This can be useful for including other pages in a template.
|
||||
|
||||
|
||||
### Output Structure
|
||||
|
||||
The output files will be generated in the specified output directory, with paths defined in the `output` attribute of your YAML files.
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! If you have suggestions or improvements, feel free to open an issue or submit a pull request.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
||||
|
||||
## Acknowledgments
|
||||
|
||||
- [Jinja2](https://jinja.palletsprojects.com/) for the templating engine.
|
||||
- [Markdown](https://python-markdown.github.io/) for content formatting.
|
||||
- [PyYAML](https://pyyaml.org/) for YAML parsing.
|
||||
|
||||
---
|
||||
|
||||
For more information, please refer to the documentation or the source code.
|
4
poetry.lock
generated
4
poetry.lock
generated
|
@ -166,5 +166,5 @@ files = [
|
|||
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.13"
|
||||
content-hash = "28e81416e88e5799eea27791da01c4da8a085dfcc5c1ec0c7583930ea5f50314"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "606b3c662a52496b2304dc7d1a5618c9dc4bac6184c0dc9e73e6547ee937f75f"
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
[tool.poetry]
|
||||
name = "grimoire"
|
||||
name = "grimoire-ssg"
|
||||
packages = [
|
||||
{ include = "grimoire-ssg" }
|
||||
]
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
description = "A minimalistic Static Site Generator"
|
||||
authors = ["Sigma <git@sigma-star.io>"]
|
||||
license = "BSD-2-Clause"
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.13"
|
||||
python = "^3.10"
|
||||
markdown = "^3.7"
|
||||
jinja2 = "^3.1.5"
|
||||
pyyaml = "^6.0.2"
|
||||
|
|
Loading…
Reference in a new issue