jtremesay / jssg

GNU Affero General Public License v3.0
1 stars 0 forks source link

JSSG - Jtremesay's Static Site Generator

CI/CD

An ever evoluting thing that propulse jtremesay.org.

Specifications

It's not a generic static site generator. It's really tailored to my needs for jtremesay.org. For most of its life, the code of jssg was merged with the content of jtremesay.org. I moved it to a separate repo because some crazy people wanted to use it for profesisonal stuff‽‽‽.

My needs:

History

JSSG was successively:

It's currently:

In the future, it will become:

Installation

  1. Install JSSG from the repo (no pypi package provided at this time):
python3 -m pip install --user https://github.com/jtremesay/jssg.git
  1. Update proj/settings.py to add the JSSG:
INSTALLED_APPS = [
    ...,
    "jssg",
]
  1. Update proj/urls.py:
from jssg.utils import jssg_urls

urlpatterns = [
    # ...
]

# Automatically declare urls for pages, posts and rss feed
urlpatterns += jssg_urls()

Configuration

You need to set the following variables in your settings.py:

Content

Just put your md files in yourapp/content/posts and yourapp/content/pages and JSSG will autodiscover them.

You have full access to the django template engine in the markdown, have fun!

Page

Ex:

---
title: Hello, world!
slug: index
---

## bla bla bla

bla bla bla

Post

Ex:

---
title: Hello, world
date: 2023-05-31T20:00+02:00
---

bla bla bla

Templating

You need to provide the page.html and post.html template.

Ex:

{% extends "base.html" %}

{% block "content" %}
Published {{ object.timestamp|date:"Y-m-d" }}.

<h1>{{ object.title }}</h1>
{{ object.content_md|safe }}
{% endblock %}

Usage

Local

Just use the good old ./manage.py runserver and build your site like a regular django project

Generate site

When your are api with your site, you can generate the static version with distill:

./manage.py distill-local --collectstatic --force dist

The dist folder contains the generated .html files and the collected statics. You can now rsync it to your webserver or whatever.