Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc 17 add usage documentation #30

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 63 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# JSSG - Jtremesay's Static Site Generator
# JFM-Engine

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an explanation, something like this: jsm-engine is a friendly fork of jssg made in agreement with the JSSG developer because of different goals. See jtremesay/jssg#21

Note: this explanation may be put at the end of the README. This is not the first information the user wants to read (but it's fair to put it on the project readme)

[![CI/CD](https://github.com/jtremesay/jssg/actions/workflows/main.yaml/badge.svg)](https://github.com/jtremesay/jssg/actions/workflows/main.yaml)

The thing that propulse [jtremesay.org](https://jtremesay.org).

Today, it's a django app that can generate a static website with Vite & Typescript integration.

## Bootstrap

```shell
$ git clone https://github.com/jtremesay/jtremesay.org.git
$ cd jtremesay.org
$ git clone https://github.com/algoo/jssg.git
$ cd jssg
$ python3.9 -m venv env/
$ source env/bin/activate
$ direnv allow
Expand Down Expand Up @@ -44,10 +41,68 @@ $ ./manage.py distill-local --collectstatic --force dist
Or, if you prefer docker:

```shell
$ docker build -t jssg .
$ sudo docker run -p 8080:80 jssg:latest
$ sudo docker build -t jssg .
$ sudo docker network create traefik_public
$ sudo docker compose up
```

## Config

### `settings.py` :
For django settings, see https://docs.djangoproject.com/en/5.0/ref/settings/

Otherwise, you have to configure the following settings :
- `JSSG_DOMAIN` : the domain name of your website, for instance `"https://www.example.com"` (used in sitemap file)
- `JSSG_CONTENT_DIR` : a list of directories where to look for the site content

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: if the var contains a list, then the naming should be explicit: JSSG_CONTENT_DIR -> JSSG_CONTENT_DIRS.

By the way, I suggest to rename it to JFME_CONTENT_DIRS (and JFME_DOMAIN)

### `Dockerfile` :
- In the `# Copy source dir` section, add `COPY <content-dir>/ <content-dir>/` for each content directory in `JSSG_CONTENT_DIR`

### `views.py` :
- In the `get_object` method of `IndexView`, set the `self.kwargs["slug"]` to the slug of your index page which is sent at the root of your site

## Usage

Each directory defined in `JSSG_CONTENT_DIR` has the following structure :
```
Content-dir/
|-- templates/
| |-- django/
| | |-- blocks/
| | |-- widgets/
| |-- jinja2/
| |-- blocks/
| |-- widgets/
| |-- base.html
| |-- page.html
| |-- post.html
| |-- sitemap.html
|-- pages/
|-- posts/
|-- static/
```

### Templates :
For Django engine, see https://docs.djangoproject.com/en/5.0/ref/templates/language/ \
For Jinja2 engine, see https://jinja.palletsprojects.com/en/2.11.x/templates/

`page.html` and `post.html` are the firsts templates called to render a page or a post. By default, they extend the `base.html` template.

### Pages :
Pages contain the content of each web page of the site at url `pages/<slug>.html`. They are `.md` files and are structured in 3 sections separated by a line starting with `---` :

- **Metadata** provide some informartion about the page (description, language...). Each metadata is a key, some spaces, and a value. The `title` metadata is required for all pages. Other metadata can be useful, like `slug`, `lang`, `template_engine` or `og:<key>` (open graph). Metadata are accessible by a dictionary in `object.metadata` in templates.
- **Data** is a section which contains a JSON text. It is accessible by `object.data` in templates.
- **Body** : It is the concrete content of the page, that can be html or template content. For instance, it is possible to use widgets or blocks in this section. It is accessible by `object.content` in templates.

### Posts :
Like pages, they contain the content of each post at url `posts/<slug>.html`. They require an additional metadata `date` in ISO format

### Static :
This directory is for the static content, like images, CSS and JavaScript files ... \
It is accessible in templates by the Jinja or Django `static` function. \
See the [Django doc](https://docs.djangoproject.com/en/5.0/howto/static-files/#configuring-static-files) for static files, or the [Jinja2 version](https://docs.djangoproject.com/en/5.0/topics/templates/#module-django.template.backends.django).

## Others

This repo is a fork of https://github.com/jtremesay/jssg.git for algoo websites use cases.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
version: "3.8"
services:
jtremesay:
image: "killruana/jtremesay.org:main"
image: "jssg"
ports:
- 8003:80
networks:
Expand Down
Loading