|
|
@@ -99,7 +99,7 @@ class Page: |
|
|
|
return self.date < other.date |
|
|
|
|
|
|
|
@staticmethod |
|
|
|
def all(source: Path): |
|
|
|
def all(source: Path, only_published=True): |
|
|
|
"""Retrieve all pages sorted by desc.""" |
|
|
|
page_list = [] |
|
|
|
for file_path in each_markdown_from(source): |
|
|
@@ -108,9 +108,15 @@ class Page: |
|
|
|
h1_opening_size = len("<h1>") |
|
|
|
title = title[h1_opening_size:] |
|
|
|
page = Page(title, content, file_path) |
|
|
|
if only_published and page.is_draft: |
|
|
|
continue |
|
|
|
page_list.append(page) |
|
|
|
return sorted(page_list, reverse=True) |
|
|
|
|
|
|
|
@property |
|
|
|
def is_draft(self): |
|
|
|
return self.date > date.today() |
|
|
|
|
|
|
|
|
|
|
|
@cli |
|
|
|
def fragment(title: str): |
|
|
@@ -124,9 +130,9 @@ def fragment(title: str): |
|
|
|
def pages(): |
|
|
|
"""Build the agregations from fragments.""" |
|
|
|
root_path = DAVID / "2020" |
|
|
|
page_list = Page.all(source=root_path) |
|
|
|
for previous, page, next_ in neighborhood( |
|
|
|
page_list, last={"url": "/david/stream/", "title": "Streams 2009-2019"} |
|
|
|
Page.all(source=root_path, only_published=False), |
|
|
|
last={"url": "/david/stream/", "title": "Streams 2009-2019"}, |
|
|
|
): |
|
|
|
template = environment.get_template("article_2020.html") |
|
|
|
content = template.render(page=page, next=previous, prev=next_,) |
|
|
@@ -134,7 +140,7 @@ def pages(): |
|
|
|
target_path.mkdir(parents=True, exist_ok=True) |
|
|
|
open(target_path / "index.html", "w").write(content) |
|
|
|
template = environment.get_template("archives_2020.html") |
|
|
|
content = template.render(page_list=page_list) |
|
|
|
content = template.render(page_list=Page.all(source=root_path)) |
|
|
|
open(root_path / "index.html", "w").write(content) |
|
|
|
|
|
|
|
|