Commit bc9410d0 authored by berumuron's avatar berumuron
Browse files

add: Support generation of a blog page

parent d9c97040
......@@ -154,6 +154,41 @@ without its extension. A default value for `author` can be set in the
`configuration.yml` file. `date` and `update` must follow this format:
Then, you'll probably want to have a page listing all the articles of your
blog. For that, you'll need to create a `templates/blog.html` file. This
template has access to a `ARTICLES` variable:
{% for article in ARTICLES %}
<a href="{{ article.url() }}">{{ article.title() }}</a>
({{"%d %b %Y") }})
{% endfor %}
This will generate a `site/blog.html` page.
`Article` model has several public methods:
- `slug()`: the name of the generated file, without its extension
- `title()`: the title of the article
- `author()`: the author of the article
- `url()`: the full URL of the article
- `uuid()`: a unique identifier, based on the URL
- `content()`: the article's content in HTML
- `date()`: the publication date
- `update()`: the last update date
The root folder can contain a `static` folder as well. Its content will be
copied under the `./site` folder:
......@@ -299,6 +299,18 @@ def main(environment):
print(f"Written article: file://{os.path.abspath(output_filepath)}")
# Write the page with the list of articles if blog template exists
blog_template_filepath = os.path.join("templates", "blog.html")
if os.path.exists(blog_template_filepath):
blog_template = boopsy.Template(blog_template_filepath)
context = {}
context["ARTICLES"] = articles
blog_output_filepath = os.path.join(output_path, f"blog.html")
with open(blog_output_filepath, "w") as output_file:
print(f"Written page: file://{os.path.abspath(blog_output_filepath)}")
# Just create some variables so it's easier to manipulate after
site_url = configuration["SITE_URL"]
site_uuid = configuration["SITE_UUID"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment