2.0 KiB
2.0 KiB
Static site generator from reStructuredText files.
Usage
Run:
git clone https://git.nxhs.cloud/ge/blog.git && cd blog
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
mkdir -p {layouts,content,assets/css/pygments}
touch settings.toml content/my_page.rst layouts/{base,index,post}.j2
make css default
Put in settings.toml:
[site]
title = 'My site'
index_page_title = 'Home page'
datetime_format = '%d %b %Y'
[build]
build_dir = 'build'
content_dir = 'content'
templates_dir = 'layouts'
assets_dir = 'assets'
[pygments]
theme = 'default'
[docutils]
Create basic Jinja2 templates.
layouts/base.j2:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="assets/css/pygments/{{ pygments_theme }}.css">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<header>
<p>
{% if posts %}
{{ site_title }}
{% else %}
<a href="/">{{ site_title }}</a> / {{ page_title }}</p>
{% endif %}
</p>
</header>
<main>
{% block content %}{% endblock %}
</main>
<footer>
</footer>
</body>
</html>
layouts/index.j2:
{% extends "base.j2" %}
{% block content %}
<section>
<ul id="posts">
{% for post in posts %}
<li>
<a href="/{{ post['path'] }}">{{post['title'] }}</a>
<span class="meta"> — {{ post['date'] }}</span>
</li>
{% endfor %}
</ul>
</section>
{% endblock %}
layouts/post.j2:
{% extends "base.j2" %}
{% block content %}
<article>
{{ post | safe }}
<article>
{% endblock %}
Put in content/my_page.rst:
:title: My first page
:date: 01 Jan 1970
=============
My first page
=============
Hello, World!
Build site:
make
See HTML in build/ dir. Write your own CSS styles.