{ "cells": [ { "cell_type": "markdown", "id": "dda60de8", "metadata": {}, "source": [ "## Roadmap\n", "\n", "- [x] Load markdown\n", "- [] Determine static website structure\n", " - Where to put assets for subsites like dogma jimfinium\n", " - How to otherwise organize pages\n", "- [x] ~~Resolve markdown links~~\n", "- [] Consider separating article templates and overall page templates\n", "- [] RSS feed\n", "\n", "\n", "WEBROOT\n", "- assets\n", "- main pages\n", "- resume\n", "- dogma-jimfinium/\n", " - assets/\n", " - pages" ] }, { "cell_type": "code", "execution_count": 11, "id": "207d2510", "metadata": {}, "outputs": [], "source": [ "import os\n", "import markdown\n", "import yaml\n", "import subprocess\n", "\n", "\n", "from datetime import datetime\n", "from main import *" ] }, { "cell_type": "code", "execution_count": 12, "id": "d2361c42", "metadata": {}, "outputs": [], "source": [ "metadata, content = load_markdown('tmp/dogma-jimfinium/blowouts.md')\n", "content = content.replace('src=\"assets', 'src=\"../tmp/dogma-jimfinium/assets')" ] }, { "cell_type": "code", "execution_count": 31, "id": "ed7b3b2f", "metadata": {}, "outputs": [], "source": [ "PARTIALS = load_partials()\n", "html = format_html_template('templates/blog_post.html', content = content, **{'metadata__'+k:v for k,v in metadata.items()}, **PARTIALS)\n", "with open('dist/home.html', 'w') as f:\n", " f.write(html)" ] }, { "cell_type": "code", "execution_count": null, "id": "b8c87620", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "57383c24", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2025-12-01\n" ] }, { "data": { "text/plain": [ "CompletedProcess(args=['cp', 'build/resume/2025-12-01/shepich_resume.pdf', 'dist/shepich_resume.pdf'], returncode=0, stdout=b'', stderr=b'')" ] }, "execution_count": 170, "metadata": {}, "output_type": "execute_result" } ], "source": [] }, { "cell_type": "code", "execution_count": 58, "id": "944a5efd", "metadata": {}, "outputs": [], "source": [ "run(f'rm -rf dist/dogma-jimfinium && mkdir -p dist/dogma-jimfinium')\n", "run(f'cp -r build/dogma-jimfinium/assets dist/dogma-jimfinium')\n", "\n", "index = {}\n", "\n", "for article in os.listdir('build/dogma-jimfinium'):\n", " metadata, content = load_markdown(f'build/dogma-jimfinium/{article}')\n", "\n", " # Skip unpublished articles.\n", " if not metadata.get('published'):\n", " continue\n", "\n", " article_filestem = os.path.splitext(article)[0]\n", "\n", " # Add the article to the index.\n", " index[article_filestem] = (metadata, content)\n", "\n", " # Interpolate the article contents into the webpage template.\n", " article_html = format_html_template(\n", " 'templates/components/blog_article.html',\n", " content = content,\n", " blog_tags = ' '.join(format_blog_tags(metadata['tags'])),\n", " **{'metadata__'+k:v for k,v in metadata.items()}\n", " )\n", " html = format_html_template('templates/simple.html', content = article_html, **PARTIALS)\n", " \n", " # Write the HTML file to /dist/dogma-jimfinium.\n", " with open(f'dist/dogma-jimfinium/{article_filestem}.html', 'w') as f:\n", " f.write(html)\n", "\n", "\n", "index_html = build_blog_archive(index, metadata__title = 'Dogma Jimfinium | Index')\n", "# Write the HTML file to /dist/dogma-jimfinium.\n", "with open(f'dist/dogma-jimfinium/index.html', 'w') as f:\n", " f.write(index_html)" ] }, { "cell_type": "code", "execution_count": null, "id": "e32458c7", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "e3171afd", "metadata": {}, "outputs": [], "source": [ "def build_blog_archive(index: dict[str, tuple[str, str]], template = 'templates/simple.html', **kwargs) -> str:\n", " '''Converts an index, formatted as filestem: (metadata, contents) dict,\n", " into an HTML page containing the list of articles, sorted from newest to oldest.'''\n", "\n", " # Add each article in the format `YYYY-MM-DD - Title`\n", " index_html_content = '