Cybrkyd's git repositories

page-with-py • commit: ab74f60

commit ab74f60d5a8aded09e6f2b512b9e917a9dec778823e7649e1c82ce7fe10e4bf9
author cybrkyd <vii@cybrkyd.com> 2025-09-20 17:17:18 +0100
committer cybrkyd <vii@cybrkyd.com> 2025-09-20 17:17:18 +0100
v0.9.10

Commit Message

- v0.9.10
- New theme template: page.html
- This is to segregate the /post/ pages from other pages

📊 Diffstat

pg-py/pg.py 25
1 files changed, 20 insertions(+), 5 deletions(-)

Diff

diff --git a/pg-py/pg.py b/pg-py/pg.py
index 2c277af..bd010b7 100644
--- a/pg-py/pg.py
+++ b/pg-py/pg.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""
PaPy (Page with Python): a Python static site generator
- v0.9.9
+ v0.9.10
"""
import re
@@ -116,6 +116,13 @@ def load_template_parts(theme_dir: Path):
templates['single'] = '<main class="single-page">\n<article class="post-content">\n{content}\n</article>\n</main>'
print("Warning: single.html not found in theme directory")
+ page_file = theme_dir / 'page.html'
+ if page_file.exists():
+ templates['page'] = page_file.read_text(encoding="utf-8")
+ else:
+ templates['page'] = templates['single']
+ print("Warning: page.html not found in theme directory, using single.html")
+
if tags_file.exists():
templates['tags'] = tags_file.read_text(encoding="utf-8")
else:
@@ -194,6 +201,14 @@ def generate_html_page(templates, title, content, description="", page_url="", i
}
main_content = render_template(content_template, context)
html = f"{templates['header']}\n{main_content}\n{templates['footer']}"
+ elif schema_type == "page":
+ content_template = templates.get('page', templates['single'])
+ context = {
+ 'content': content,
+ 'title': title
+ }
+ main_content = render_template(content_template, context)
+ html = f"{templates['header']}\n{main_content}\n{templates['footer']}"
else:
html = f"{templates['header']}\n{content}\n{templates['footer']}"
@@ -268,10 +283,10 @@ def process_markdown_file(md_path: Path, templates, output_dir: Path, is_post=Fa
else:
output_path = output_dir / base_name / 'index.html'
page_url = f"{SITE_URL}/{base_name}/"
-
- full_html = generate_html_page(templates, title, html_content, description, page_url, image, "article", date_str, image_data, caption_data, post_navigation="")
-
-
+
+ schema_type = "article" if is_post else "page"
+ full_html = generate_html_page(templates, title, html_content, description, page_url, image, schema_type, date_str, image_data, caption_data, post_navigation="")
+
write_html_file(output_path, full_html)
return {