refactor #1

Merged
jim merged 20 commits from refactor into main 2026-02-03 01:08:46 -05:00
3 changed files with 8 additions and 8 deletions
Showing only changes of commit ab94ee0bab - Show all commits

View File

@ -76,7 +76,7 @@ def build_site(site: SiteConfig, templates: DotMap):
def main(): def main():
logger.info('Loading config.') logger.info('Loading config.')
with open('/home/jim/projects/shepich.com/config.yaml', 'r') as config_file: with open('./config.yaml', 'r') as config_file:
config = yaml.safe_load(config_file.read()) config = yaml.safe_load(config_file.read())
logger.info('Loading global templates.') logger.info('Loading global templates.')

View File

@ -3,7 +3,7 @@ import glob
import yaml import yaml
import markdown import markdown
import pydantic import pydantic
from typing import Optional from typing import Optional, Union
from dotmap import DotMap from dotmap import DotMap
from datetime import date from datetime import date
@ -26,7 +26,7 @@ class Article(pydantic.BaseModel):
metadata: Optional[ArticleMetadata] = None metadata: Optional[ArticleMetadata] = None
def load_markdown(md: str) -> tuple[ArticleMetadata|None, str]: def load_markdown(md: str) -> tuple[Optional[ArticleMetadata], str]:
'''Loads a Markdown file into a (metadata: ArticleMetadata, content: str) pair.''' '''Loads a Markdown file into a (metadata: ArticleMetadata, content: str) pair.'''
# Load the file contents if a filepath is specified, and strip document delimiters ('---'). # Load the file contents if a filepath is specified, and strip document delimiters ('---').
@ -59,7 +59,7 @@ def build_index(site: SiteConfig) -> dict[str, Article]:
for a in site.articles or {}: for a in site.articles or {}:
expanded_article_list.extend( expanded_article_list.extend(
# Article paths are defined relative to the build cache; construct the full path. # Article paths are defined relative to the build cache; construct the full path.
glob.glob(f'{site.build_cache}/{a.removeprefix('./').lstrip("/")}') glob.glob(f"{site.build_cache}/{a.removeprefix('./').lstrip('/')}")
) )

View File

@ -103,21 +103,21 @@ def build_blog_archive(
**kwargs **kwargs
) )
with open(f'{site.web_root.rstrip('/')}/archive.html', 'w') as f: with open(f"{site.web_root.rstrip('/')}/archive.html", 'w') as f:
f.write(archive_html_page) f.write(archive_html_page)
def build_rss_feed(site: SiteConfig, index: dict[str, Article]): def build_rss_feed(site: SiteConfig, index: dict[str, Article]):
feed = rfeed.Feed( feed = rfeed.Feed(
title = site.title, title = site.title,
link = f'{site.base_url.rstrip('/')}/rss.xml', link = f"{site.base_url.rstrip('/')}/rss.xml",
description = site.description, description = site.description,
language = "en-US", language = "en-US",
lastBuildDate = datetime.now(), lastBuildDate = datetime.now(),
items = [ items = [
rfeed.Item( rfeed.Item(
title = article.metadata.title, title = article.metadata.title,
link = f'{site.base_url.rstrip('/')}/{article.path}', link = f"{site.base_url.rstrip('/')}/{article.path}",
description = article.metadata.description, description = article.metadata.description,
author = article.metadata.author, author = article.metadata.author,
guid = rfeed.Guid(article.path), guid = rfeed.Guid(article.path),
@ -131,5 +131,5 @@ def build_rss_feed(site: SiteConfig, index: dict[str, Article]):
] ]
) )
with open(f'{site.web_root.rstrip('/')}/rss.xml', 'w') as f: with open(f"{site.web_root.rstrip('/')}/rss.xml", 'w') as f:
f.write(feed.rss()) f.write(feed.rss())