From bfe20aa6f0911843ca494b26e848cd27b7701ae6 Mon Sep 17 00:00:00 2001
From: ado
Date: Sat, 25 Nov 2023 08:12:52 -0500
Subject: [PATCH] simple sample
---
generate.py | 45 +++++++++++++++++++++++++++++++++++++++++++++
index.css | 19 +++++++++++++++++++
index.html | 28 ++++++++++++++++++++++++++++
input/art-001.html | 5 +++++
input/template.html | 24 ++++++++++++++++++++++++
5 files changed, 121 insertions(+)
create mode 100644 generate.py
create mode 100644 index.css
create mode 100644 index.html
create mode 100644 input/art-001.html
create mode 100644 input/template.html
diff --git a/generate.py b/generate.py
new file mode 100644
index 0000000..a6a93dd
--- /dev/null
+++ b/generate.py
@@ -0,0 +1,45 @@
+from dataclasses import dataclass
+from pathlib import Path
+import re
+
+
+@dataclass
+class Article:
+ path: str
+
+ def read_contents(self) -> str:
+ return Path(self.path).read_text()
+
+
+articles = [
+ Article(
+ "./input/art-001.html",
+ ),
+]
+
+# generate slugs and read articles
+slugs = []
+article_contents = []
+for article in articles:
+ contents = article.read_contents()
+ id_match = re.search(r'
"""
+ slugs.append(slug)
+
+# plug into template, write to index.html
+template = Path("./input/template.html").read_text()
+template = template.replace(
+ "", "\n".join(article_contents)
+)
+template = template.replace("", "\n".join(slugs))
+with open("./index.html", "w", encoding="utf-8") as index_html:
+ index_html.write(template)
diff --git a/index.css b/index.css
new file mode 100644
index 0000000..cbfcff8
--- /dev/null
+++ b/index.css
@@ -0,0 +1,19 @@
+:root {
+ --text-color: #f7f7f7;
+ --bg-color: #19232f;
+}
+
+@media (prefers-color-scheme: light) {
+ :root {
+ --text-color: #222430;
+ --bg-color: #f7f7f7;
+ }
+}
+
+@media only screen and (min-width: 768px) {
+ .container {
+ display: grid;
+ grid-template-columns: 2.75fr 1.25fr;
+ margin-top: 2rem;
+ }
+}
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..3bb0d76
--- /dev/null
+++ b/index.html
@@ -0,0 +1,28 @@
+
+
+
+
+
+ Page Title
+
+
+
+
+
+
+
+
+
+ My Article Title
+ Any HTML you please
+
+
Also any HTML you please, I like to put images between articles
+
+
+
+
+
diff --git a/input/art-001.html b/input/art-001.html
new file mode 100644
index 0000000..894e46b
--- /dev/null
+++ b/input/art-001.html
@@ -0,0 +1,5 @@
+
+ My Article Title
+ Any HTML you please
+
+Also any HTML you please, I like to put images between articles
diff --git a/input/template.html b/input/template.html
new file mode 100644
index 0000000..4033343
--- /dev/null
+++ b/input/template.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+ Page Title
+
+
+
+
+
+
+
+
+