aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-15 18:17:10 -0400
committerhistoria <[not public]>2026-06-15 18:17:10 -0400
commitfec892047e4c0b810981fa8f20223e0b1c4f72b4 (patch)
treea6fdc109a3a32ae383a88d01ba44322be4b8bcc3
parent193666c2bba01bb9bc1a21ac270c0affe15ea757 (diff)
downloadssg-blog-fec892047e4c0b810981fa8f20223e0b1c4f72b4.tar.gz
refactor. added rss feed.
-rw-r--r--README.md12
-rw-r--r--demo/demo.webpbin0 -> 19374 bytes
-rw-r--r--demo/dst/.files (renamed from example/dst/.files)13
-rw-r--r--demo/dst/404.html32
-rw-r--r--demo/dst/about.html32
-rw-r--r--demo/dst/articles/an-interesting-article/assets/stamps.webp (renamed from example/dst/articles/an-interesting-article/assets/stamps.webp)bin46960 -> 46960 bytes
-rw-r--r--demo/dst/articles/an-interesting-article/index.html34
-rw-r--r--demo/dst/articles/another-interesting-article/assets/japanese-train.webp (renamed from example/dst/articles/another-interesting-article/assets/japanese-train.webp)bin128168 -> 128168 bytes
-rw-r--r--demo/dst/articles/another-interesting-article/index.html34
-rw-r--r--demo/dst/articles/article3.html32
-rw-r--r--demo/dst/favicon.png (renamed from example/dst/favicon.png)bin393 -> 393 bytes
-rw-r--r--demo/dst/index.html37
-rw-r--r--demo/dst/lists/board-games.html (renamed from example/dst/lists/board-games.html)23
-rw-r--r--demo/dst/lists/movies.html (renamed from example/dst/lists/movies.html)23
-rw-r--r--demo/dst/rss.xml39
-rw-r--r--demo/dst/sitemap.xml (renamed from example/dst/sitemap.xml)14
-rw-r--r--demo/dst/style.css (renamed from example/dst/style.css)0
-rw-r--r--demo/example.webp (renamed from example/example.webp)bin15022 -> 15022 bytes
-rw-r--r--demo/src/404.md (renamed from example/src/404.md)0
-rw-r--r--demo/src/_footer.html (renamed from example/src/_footer.html)0
-rw-r--r--demo/src/_header.html28
-rw-r--r--demo/src/about.md (renamed from example/src/about.md)0
-rw-r--r--demo/src/articles/an-interesting-article/assets/stamps.webp (renamed from example/src/articles/an-interesting-article/assets/stamps.webp)bin46960 -> 46960 bytes
-rw-r--r--demo/src/articles/an-interesting-article/index.md (renamed from example/src/articles/an-interesting-article/index.md)0
-rw-r--r--demo/src/articles/another-interesting-article/assets/japanese-train.webp (renamed from example/src/articles/another-interesting-article/assets/japanese-train.webp)bin128168 -> 128168 bytes
-rw-r--r--demo/src/articles/another-interesting-article/index.md (renamed from example/src/articles/another-interesting-article/index.md)0
-rw-r--r--demo/src/articles/article3.md (renamed from example/src/articles/article3.md)0
-rw-r--r--demo/src/favicon.png (renamed from example/src/favicon.png)bin393 -> 393 bytes
-rw-r--r--demo/src/lists/board-games.md (renamed from example/src/lists/board-games.md)0
-rw-r--r--demo/src/lists/movies.md (renamed from example/src/lists/movies.md)0
-rw-r--r--demo/src/style.css (renamed from example/src/style.css)0
-rw-r--r--example/dst/404.html33
-rw-r--r--example/dst/about.html33
-rw-r--r--example/dst/articles/an-interesting-article/index.html37
-rw-r--r--example/dst/articles/another-interesting-article/index.html37
-rw-r--r--example/dst/articles/article3.html33
-rw-r--r--example/dst/index.html41
-rw-r--r--example/src/_header.html28
-rwxr-xr-xssg-blog167
39 files changed, 411 insertions, 351 deletions
diff --git a/README.md b/README.md
index 1dd1461..8423c32 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,9 @@
This is a modification to the simple static site generator '[ssg](https://romanzolotarev.com/bin/ssg)' by Roman Zolotarev. This is a markdown to HTML static site generator that also creates a minimal blog index page with category headings and posts sorted by date using YAML frontmatter in markdown files.
-![example](example/example.webp)
+It also generates a sitemap.xml and rss.xml file.
+
+![demo of generated site](demo/demo.webp)
# Install / Usage
@@ -23,16 +25,16 @@ publish: false
---
```
-If a file has no frontmatter, no `date`, or `publish: false`, the page won't be included in the index. It will still be rendered in sitemap.xml.
+If a file has no frontmatter, no `date`, or `publish: false`, the page won't be included in the index, sitemap, or RSS feed.
Setting `publish: true` is optional and equivalent to not having `publish` at all.
-## Example
+## Demo
-There is an example directory in this repo to show you how to set up the files (src) and what the output looks like (dst). This was the command used to generate the example output:
+There is a demo directory in this repo to show you an example of how to set up the files (src) and what the output looks like (dst). This was the command used to generate the demo output:
```
-./ssg-blog example/src example/dst 'https://example.org'
+./ssg-blog demo/src demo/dst 'https://example.org'
```
Note a few things about the output:
diff --git a/demo/demo.webp b/demo/demo.webp
new file mode 100644
index 0000000..40f42d0
--- /dev/null
+++ b/demo/demo.webp
Binary files differ
diff --git a/example/dst/.files b/demo/dst/.files
index 331242d..f7d8b18 100644
--- a/example/dst/.files
+++ b/demo/dst/.files
@@ -1,11 +1,8 @@
-./style.css
-./lists/board-games.md
+./404.md
+./about.md
./lists/movies.md
+./lists/board-games.md
./articles/an-interesting-article/index.md
-./articles/an-interesting-article/assets/stamps.webp
-./articles/another-interesting-article/index.md
-./articles/another-interesting-article/assets/japanese-train.webp
./articles/article3.md
-./about.md
-./404.md
-./favicon.png
+./articles/another-interesting-article/index.md
+./style.css
diff --git a/demo/dst/404.html b/demo/dst/404.html
new file mode 100644
index 0000000..b6e2d1e
--- /dev/null
+++ b/demo/dst/404.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <link rel="icon" type="image/png" href="https://example.org/favicon.png">
+ <link rel="stylesheet" href="style.css">
+ <title></title>
+</head>
+<body>
+<div class="container">
+<a id="header" href="https://example.org">
+<pre>
+ _____ _
+ | ____|_ ____ _ _ __ ___ _ __ | | ___
+ | _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \
+ | |___ > < (_| | | | | | | |_) | | __/
+ |_____/_/\_\__,_|_| |_| |_| .__/|_|\___|
+ |_|
+ example.org
+</pre>
+</a>
+<div id="navigation">
+<a href="https://example.org/">Home</a> -
+<a href="https://codeberg.org/">Repos</a> -
+<a href="https://example.org/rss.xml">RSS</a> -
+<a href="https://example.org/about.html">About</a>
+</div>
+</div>
+<h1 id="404-not-found">404 Not Found</h1>
+<p>I couldn&#8217;t find that page.</p>
+</body>
+</html>
diff --git a/demo/dst/about.html b/demo/dst/about.html
new file mode 100644
index 0000000..b17b7fe
--- /dev/null
+++ b/demo/dst/about.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <link rel="icon" type="image/png" href="https://example.org/favicon.png">
+ <link rel="stylesheet" href="style.css">
+ <title></title>
+</head>
+<body>
+<div class="container">
+<a id="header" href="https://example.org">
+<pre>
+ _____ _
+ | ____|_ ____ _ _ __ ___ _ __ | | ___
+ | _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \
+ | |___ > < (_| | | | | | | |_) | | __/
+ |_____/_/\_\__,_|_| |_| |_| .__/|_|\___|
+ |_|
+ example.org
+</pre>
+</a>
+<div id="navigation">
+<a href="https://example.org/">Home</a> -
+<a href="https://codeberg.org/">Repos</a> -
+<a href="https://example.org/rss.xml">RSS</a> -
+<a href="https://example.org/about.html">About</a>
+</div>
+</div>
+<h1 id="about">About</h1>
+<p>Here is an about page for my website</p>
+</body>
+</html>
diff --git a/example/dst/articles/an-interesting-article/assets/stamps.webp b/demo/dst/articles/an-interesting-article/assets/stamps.webp
index 9785ce7..9785ce7 100644
--- a/example/dst/articles/an-interesting-article/assets/stamps.webp
+++ b/demo/dst/articles/an-interesting-article/assets/stamps.webp
Binary files differ
diff --git a/demo/dst/articles/an-interesting-article/index.html b/demo/dst/articles/an-interesting-article/index.html
new file mode 100644
index 0000000..ea236df
--- /dev/null
+++ b/demo/dst/articles/an-interesting-article/index.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <link rel="icon" type="image/png" href="https://example.org/favicon.png">
+ <link rel="stylesheet" href="style.css">
+ <title>This is a very interesting article about stamps</title>
+</head>
+<body>
+<div class="container">
+<a id="header" href="https://example.org">
+<pre>
+ _____ _
+ | ____|_ ____ _ _ __ ___ _ __ | | ___
+ | _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \
+ | |___ > < (_| | | | | | | |_) | | __/
+ |_____/_/\_\__,_|_| |_| |_| .__/|_|\___|
+ |_|
+ example.org
+</pre>
+</a>
+<div id="navigation">
+<a href="https://example.org/">Home</a> -
+<a href="https://codeberg.org/">Repos</a> -
+<a href="https://example.org/rss.xml">RSS</a> -
+<a href="https://example.org/about.html">About</a>
+</div>
+</div>
+<h1 id="this-is-a-very-interesting-article-about-stamps">This is a very interesting article about stamps</h1>
+<p>Here is a picture of some cool stamps</p>
+<p><img src="assets/stamps.webp" alt="" /></p>
+<p>Thank you for reading my nice article.</p>
+</body>
+</html>
diff --git a/example/dst/articles/another-interesting-article/assets/japanese-train.webp b/demo/dst/articles/another-interesting-article/assets/japanese-train.webp
index c4cab3e..c4cab3e 100644
--- a/example/dst/articles/another-interesting-article/assets/japanese-train.webp
+++ b/demo/dst/articles/another-interesting-article/assets/japanese-train.webp
Binary files differ
diff --git a/demo/dst/articles/another-interesting-article/index.html b/demo/dst/articles/another-interesting-article/index.html
new file mode 100644
index 0000000..bc82292
--- /dev/null
+++ b/demo/dst/articles/another-interesting-article/index.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <link rel="icon" type="image/png" href="https://example.org/favicon.png">
+ <link rel="stylesheet" href="style.css">
+ <title>I love trains</title>
+</head>
+<body>
+<div class="container">
+<a id="header" href="https://example.org">
+<pre>
+ _____ _
+ | ____|_ ____ _ _ __ ___ _ __ | | ___
+ | _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \
+ | |___ > < (_| | | | | | | |_) | | __/
+ |_____/_/\_\__,_|_| |_| |_| .__/|_|\___|
+ |_|
+ example.org
+</pre>
+</a>
+<div id="navigation">
+<a href="https://example.org/">Home</a> -
+<a href="https://codeberg.org/">Repos</a> -
+<a href="https://example.org/rss.xml">RSS</a> -
+<a href="https://example.org/about.html">About</a>
+</div>
+</div>
+<h1 id="i-love-trains">I love trains</h1>
+<p>Aren&#8217;t Japanese trains great? I particularly like the boxy ones. Here is a picture of a train:</p>
+<p><img src="assets/japanese-train.webp" alt="" /></p>
+<p>Thank you for looking at this train</p>
+</body>
+</html>
diff --git a/demo/dst/articles/article3.html b/demo/dst/articles/article3.html
new file mode 100644
index 0000000..2b2c5f9
--- /dev/null
+++ b/demo/dst/articles/article3.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <link rel="icon" type="image/png" href="https://example.org/favicon.png">
+ <link rel="stylesheet" href="style.css">
+ <title>This is a third article!</title>
+</head>
+<body>
+<div class="container">
+<a id="header" href="https://example.org">
+<pre>
+ _____ _
+ | ____|_ ____ _ _ __ ___ _ __ | | ___
+ | _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \
+ | |___ > < (_| | | | | | | |_) | | __/
+ |_____/_/\_\__,_|_| |_| |_| .__/|_|\___|
+ |_|
+ example.org
+</pre>
+</a>
+<div id="navigation">
+<a href="https://example.org/">Home</a> -
+<a href="https://codeberg.org/">Repos</a> -
+<a href="https://example.org/rss.xml">RSS</a> -
+<a href="https://example.org/about.html">About</a>
+</div>
+</div>
+<h1 id="article-3">Article 3</h1>
+<p>Wow another one</p>
+</body>
+</html>
diff --git a/example/dst/favicon.png b/demo/dst/favicon.png
index 4c22246..4c22246 100644
--- a/example/dst/favicon.png
+++ b/demo/dst/favicon.png
Binary files differ
diff --git a/demo/dst/index.html b/demo/dst/index.html
new file mode 100644
index 0000000..bfc86b6
--- /dev/null
+++ b/demo/dst/index.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <link rel="icon" type="image/png" href="https://example.org/favicon.png">
+ <link rel="stylesheet" href="style.css">
+ <title>Example</title>
+</head>
+<body>
+<div class="container">
+<a id="header" href="https://example.org">
+<pre>
+ _____ _
+ | ____|_ ____ _ _ __ ___ _ __ | | ___
+ | _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \
+ | |___ > < (_| | | | | | | |_) | | __/
+ |_____/_/\_\__,_|_| |_| |_| .__/|_|\___|
+ |_|
+ example.org
+</pre>
+</a>
+<div id="navigation">
+<a href="https://example.org/">Home</a> -
+<a href="https://codeberg.org/">Repos</a> -
+<a href="https://example.org/rss.xml">RSS</a> -
+<a href="https://example.org/about.html">About</a>
+</div>
+</div>
+<h1>Articles</h1>
+2024-10-04: <a href="https://example.org/articles/an-interesting-article/">This is a very interesting article about stamps</a><br />
+2024-09-10: <a href="https://example.org/articles/another-interesting-article/">I love trains</a><br />
+2023-10-08: <a href="https://example.org/articles/article3.html">This is a third article!</a><br />
+<h1>Lists</h1>
+2024-07-12: <a href="https://example.org/lists/board-games.html">Board games</a><br />
+2022-06-05: <a href="https://example.org/lists/movies.html">Movies</a><br />
+</body>
+</html>
diff --git a/example/dst/lists/board-games.html b/demo/dst/lists/board-games.html
index 5a54f33..b85ce6b 100644
--- a/example/dst/lists/board-games.html
+++ b/demo/dst/lists/board-games.html
@@ -4,38 +4,35 @@
<meta charset="UTF-8">
<link rel="icon" type="image/png" href="https://example.org/favicon.png">
<link rel="stylesheet" href="style.css">
- <title>Example</title>
+ <title>Board games</title>
</head>
<body>
<div class="container">
<a id="header" href="https://example.org">
<pre>
-
-▄███▄ ▄ ██ █▀▄▀█ █ ▄▄ █ ▄███▄
-█▀ ▀ ▀▄ █ █ █ █ █ █ █ █ █ █▀ ▀
-██▄▄ █ ▀ █▄▄█ █ ▄ █ █▀▀▀ █ ██▄▄
-█▄ ▄▀ ▄ █ █ █ █ █ █ ███▄ █▄ ▄▀
-▀███▀ █ ▀▄ █ █ █ ▀ ▀███▀
- ▀ █ ▀ ▀
- ▀
+ _____ _
+ | ____|_ ____ _ _ __ ___ _ __ | | ___
+ | _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \
+ | |___ > < (_| | | | | | | |_) | | __/
+ |_____/_/\_\__,_|_| |_| |_| .__/|_|\___|
+ |_|
+ example.org
</pre>
</a>
<div id="navigation">
<a href="https://example.org/">Home</a> -
<a href="https://codeberg.org/">Repos</a> -
+<a href="https://example.org/rss.xml">RSS</a> -
<a href="https://example.org/about.html">About</a>
</div>
</div>
-<h1>Board Games</h1>
-
+<h1 id="board-games">Board Games</h1>
<p>Here are some board games I like:</p>
-
<ol>
<li>Puerto Rico</li>
<li>Ascension: Chronicle of the Godslayer</li>
<li>Twilight Struggle</li>
</ol>
-
<p>Play them with me, thanks.</p>
</body>
</html>
diff --git a/example/dst/lists/movies.html b/demo/dst/lists/movies.html
index dc7fc57..496e0d1 100644
--- a/example/dst/lists/movies.html
+++ b/demo/dst/lists/movies.html
@@ -4,38 +4,35 @@
<meta charset="UTF-8">
<link rel="icon" type="image/png" href="https://example.org/favicon.png">
<link rel="stylesheet" href="style.css">
- <title>Example</title>
+ <title>Movies</title>
</head>
<body>
<div class="container">
<a id="header" href="https://example.org">
<pre>
-
-▄███▄ ▄ ██ █▀▄▀█ █ ▄▄ █ ▄███▄
-█▀ ▀ ▀▄ █ █ █ █ █ █ █ █ █ █▀ ▀
-██▄▄ █ ▀ █▄▄█ █ ▄ █ █▀▀▀ █ ██▄▄
-█▄ ▄▀ ▄ █ █ █ █ █ █ ███▄ █▄ ▄▀
-▀███▀ █ ▀▄ █ █ █ ▀ ▀███▀
- ▀ █ ▀ ▀
- ▀
+ _____ _
+ | ____|_ ____ _ _ __ ___ _ __ | | ___
+ | _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \
+ | |___ > < (_| | | | | | | |_) | | __/
+ |_____/_/\_\__,_|_| |_| |_| .__/|_|\___|
+ |_|
+ example.org
</pre>
</a>
<div id="navigation">
<a href="https://example.org/">Home</a> -
<a href="https://codeberg.org/">Repos</a> -
+<a href="https://example.org/rss.xml">RSS</a> -
<a href="https://example.org/about.html">About</a>
</div>
</div>
-<h1>A List of Movies</h1>
-
+<h1 id="a-list-of-movies">A List of Movies</h1>
<p>Here are my favorite movies</p>
-
<ol>
<li>Primer</li>
<li>The Lighthouse</li>
<li>Tetsuo: The Iron Man</li>
</ol>
-
<p>I hope you enjoyed this insightful article.</p>
</body>
</html>
diff --git a/demo/dst/rss.xml b/demo/dst/rss.xml
new file mode 100644
index 0000000..34d2e0a
--- /dev/null
+++ b/demo/dst/rss.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
+<channel>
+<title>Blog</title>
+<link>https://example.org/</link>
+<description>Blog</description>
+<atom:link href="https://example.org/rss.xml" rel="self" type="application/rss+xml"/>
+<item>
+<title>This is a very interesting article about stamps</title>
+<link>https://example.org/articles/an-interesting-article/</link>
+<guid>https://example.org/articles/an-interesting-article/</guid>
+<pubDate>Fri, 04 Oct 2024 00:00:00 GMT</pubDate>
+</item>
+<item>
+<title>I love trains</title>
+<link>https://example.org/articles/another-interesting-article/</link>
+<guid>https://example.org/articles/another-interesting-article/</guid>
+<pubDate>Tue, 10 Sep 2024 00:00:00 GMT</pubDate>
+</item>
+<item>
+<title>Board games</title>
+<link>https://example.org/lists/board-games.html</link>
+<guid>https://example.org/lists/board-games.html</guid>
+<pubDate>Fri, 12 Jul 2024 00:00:00 GMT</pubDate>
+</item>
+<item>
+<title>This is a third article!</title>
+<link>https://example.org/articles/article3.html</link>
+<guid>https://example.org/articles/article3.html</guid>
+<pubDate>Sun, 08 Oct 2023 00:00:00 GMT</pubDate>
+</item>
+<item>
+<title>Movies</title>
+<link>https://example.org/lists/movies.html</link>
+<guid>https://example.org/lists/movies.html</guid>
+<pubDate>Sun, 05 Jun 2022 00:00:00 GMT</pubDate>
+</item>
+</channel>
+</rss>
diff --git a/example/dst/sitemap.xml b/demo/dst/sitemap.xml
index 945ab51..6d48f32 100644
--- a/example/dst/sitemap.xml
+++ b/demo/dst/sitemap.xml
@@ -4,11 +4,11 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
-<url><loc>https://example.org/lists/board-games.html</loc><lastmod>2024-10-10</lastmod><priority>1.0</priority></url>
-<url><loc>https://example.org/lists/movies.html</loc><lastmod>2024-10-10</lastmod><priority>1.0</priority></url>
-<url><loc>https://example.org/articles/an-interesting-article/</loc><lastmod>2024-10-10</lastmod><priority>1.0</priority></url>
-<url><loc>https://example.org/articles/another-interesting-article/</loc><lastmod>2024-10-10</lastmod><priority>1.0</priority></url>
-<url><loc>https://example.org/articles/article3.html</loc><lastmod>2024-10-10</lastmod><priority>1.0</priority></url>
-<url><loc>https://example.org/about.html</loc><lastmod>2024-10-10</lastmod><priority>1.0</priority></url>
-<url><loc>https://example.org/404.html</loc><lastmod>2024-10-10</lastmod><priority>1.0</priority></url>
+<url><loc>https://example.org/404.html</loc><lastmod>2026-06-15</lastmod><priority>1.0</priority></url>
+<url><loc>https://example.org/about.html</loc><lastmod>2026-06-15</lastmod><priority>1.0</priority></url>
+<url><loc>https://example.org/lists/movies.html</loc><lastmod>2026-06-15</lastmod><priority>1.0</priority></url>
+<url><loc>https://example.org/lists/board-games.html</loc><lastmod>2026-06-15</lastmod><priority>1.0</priority></url>
+<url><loc>https://example.org/articles/an-interesting-article/</loc><lastmod>2026-06-15</lastmod><priority>1.0</priority></url>
+<url><loc>https://example.org/articles/article3.html</loc><lastmod>2026-06-15</lastmod><priority>1.0</priority></url>
+<url><loc>https://example.org/articles/another-interesting-article/</loc><lastmod>2026-06-15</lastmod><priority>1.0</priority></url>
</urlset>
diff --git a/example/dst/style.css b/demo/dst/style.css
index 5080521..5080521 100644
--- a/example/dst/style.css
+++ b/demo/dst/style.css
diff --git a/example/example.webp b/demo/example.webp
index d9153d9..d9153d9 100644
--- a/example/example.webp
+++ b/demo/example.webp
Binary files differ
diff --git a/example/src/404.md b/demo/src/404.md
index a0aa728..a0aa728 100644
--- a/example/src/404.md
+++ b/demo/src/404.md
diff --git a/example/src/_footer.html b/demo/src/_footer.html
index 308b1d0..308b1d0 100644
--- a/example/src/_footer.html
+++ b/demo/src/_footer.html
diff --git a/demo/src/_header.html b/demo/src/_header.html
new file mode 100644
index 0000000..ca28d40
--- /dev/null
+++ b/demo/src/_header.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <link rel="icon" type="image/png" href="https://example.org/favicon.png">
+ <link rel="stylesheet" href="style.css">
+ <title>Example</title>
+</head>
+<body>
+<div class="container">
+<a id="header" href="https://example.org">
+<pre>
+ _____ _
+ | ____|_ ____ _ _ __ ___ _ __ | | ___
+ | _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \
+ | |___ > < (_| | | | | | | |_) | | __/
+ |_____/_/\_\__,_|_| |_| |_| .__/|_|\___|
+ |_|
+ example.org
+</pre>
+</a>
+<div id="navigation">
+<a href="https://example.org/">Home</a> -
+<a href="https://codeberg.org/">Repos</a> -
+<a href="https://example.org/rss.xml">RSS</a> -
+<a href="https://example.org/about.html">About</a>
+</div>
+</div>
diff --git a/example/src/about.md b/demo/src/about.md
index 1b073d8..1b073d8 100644
--- a/example/src/about.md
+++ b/demo/src/about.md
diff --git a/example/src/articles/an-interesting-article/assets/stamps.webp b/demo/src/articles/an-interesting-article/assets/stamps.webp
index 9785ce7..9785ce7 100644
--- a/example/src/articles/an-interesting-article/assets/stamps.webp
+++ b/demo/src/articles/an-interesting-article/assets/stamps.webp
Binary files differ
diff --git a/example/src/articles/an-interesting-article/index.md b/demo/src/articles/an-interesting-article/index.md
index 779f4b6..779f4b6 100644
--- a/example/src/articles/an-interesting-article/index.md
+++ b/demo/src/articles/an-interesting-article/index.md
diff --git a/example/src/articles/another-interesting-article/assets/japanese-train.webp b/demo/src/articles/another-interesting-article/assets/japanese-train.webp
index c4cab3e..c4cab3e 100644
--- a/example/src/articles/another-interesting-article/assets/japanese-train.webp
+++ b/demo/src/articles/another-interesting-article/assets/japanese-train.webp
Binary files differ
diff --git a/example/src/articles/another-interesting-article/index.md b/demo/src/articles/another-interesting-article/index.md
index 4e5d9b7..4e5d9b7 100644
--- a/example/src/articles/another-interesting-article/index.md
+++ b/demo/src/articles/another-interesting-article/index.md
diff --git a/example/src/articles/article3.md b/demo/src/articles/article3.md
index c98ebba..c98ebba 100644
--- a/example/src/articles/article3.md
+++ b/demo/src/articles/article3.md
diff --git a/example/src/favicon.png b/demo/src/favicon.png
index 4c22246..4c22246 100644
--- a/example/src/favicon.png
+++ b/demo/src/favicon.png
Binary files differ
diff --git a/example/src/lists/board-games.md b/demo/src/lists/board-games.md
index 6a40080..6a40080 100644
--- a/example/src/lists/board-games.md
+++ b/demo/src/lists/board-games.md
diff --git a/example/src/lists/movies.md b/demo/src/lists/movies.md
index 92d82e6..92d82e6 100644
--- a/example/src/lists/movies.md
+++ b/demo/src/lists/movies.md
diff --git a/example/src/style.css b/demo/src/style.css
index 5080521..5080521 100644
--- a/example/src/style.css
+++ b/demo/src/style.css
diff --git a/example/dst/404.html b/example/dst/404.html
deleted file mode 100644
index 4a91725..0000000
--- a/example/dst/404.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <link rel="icon" type="image/png" href="https://example.org/favicon.png">
- <link rel="stylesheet" href="style.css">
- <title>Example</title>
-</head>
-<body>
-<div class="container">
-<a id="header" href="https://example.org">
-<pre>
-
-▄███▄ ▄ ██ █▀▄▀█ █ ▄▄ █ ▄███▄
-█▀ ▀ ▀▄ █ █ █ █ █ █ █ █ █ █▀ ▀
-██▄▄ █ ▀ █▄▄█ █ ▄ █ █▀▀▀ █ ██▄▄
-█▄ ▄▀ ▄ █ █ █ █ █ █ ███▄ █▄ ▄▀
-▀███▀ █ ▀▄ █ █ █ ▀ ▀███▀
- ▀ █ ▀ ▀
- ▀
-</pre>
-</a>
-<div id="navigation">
-<a href="https://example.org/">Home</a> -
-<a href="https://codeberg.org/">Repos</a> -
-<a href="https://example.org/about.html">About</a>
-</div>
-</div>
-<h1>404 Not Found</h1>
-
-<p>I couldn't find that page.</p>
-</body>
-</html>
diff --git a/example/dst/about.html b/example/dst/about.html
deleted file mode 100644
index 89a14bf..0000000
--- a/example/dst/about.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <link rel="icon" type="image/png" href="https://example.org/favicon.png">
- <link rel="stylesheet" href="style.css">
- <title>Example</title>
-</head>
-<body>
-<div class="container">
-<a id="header" href="https://example.org">
-<pre>
-
-▄███▄ ▄ ██ █▀▄▀█ █ ▄▄ █ ▄███▄
-█▀ ▀ ▀▄ █ █ █ █ █ █ █ █ █ █▀ ▀
-██▄▄ █ ▀ █▄▄█ █ ▄ █ █▀▀▀ █ ██▄▄
-█▄ ▄▀ ▄ █ █ █ █ █ █ ███▄ █▄ ▄▀
-▀███▀ █ ▀▄ █ █ █ ▀ ▀███▀
- ▀ █ ▀ ▀
- ▀
-</pre>
-</a>
-<div id="navigation">
-<a href="https://example.org/">Home</a> -
-<a href="https://codeberg.org/">Repos</a> -
-<a href="https://example.org/about.html">About</a>
-</div>
-</div>
-<h1>About</h1>
-
-<p>Here is an about page for my website</p>
-</body>
-</html>
diff --git a/example/dst/articles/an-interesting-article/index.html b/example/dst/articles/an-interesting-article/index.html
deleted file mode 100644
index 8e65041..0000000
--- a/example/dst/articles/an-interesting-article/index.html
+++ /dev/null
@@ -1,37 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <link rel="icon" type="image/png" href="https://example.org/favicon.png">
- <link rel="stylesheet" href="style.css">
- <title>Example</title>
-</head>
-<body>
-<div class="container">
-<a id="header" href="https://example.org">
-<pre>
-
-▄███▄ ▄ ██ █▀▄▀█ █ ▄▄ █ ▄███▄
-█▀ ▀ ▀▄ █ █ █ █ █ █ █ █ █ █▀ ▀
-██▄▄ █ ▀ █▄▄█ █ ▄ █ █▀▀▀ █ ██▄▄
-█▄ ▄▀ ▄ █ █ █ █ █ █ ███▄ █▄ ▄▀
-▀███▀ █ ▀▄ █ █ █ ▀ ▀███▀
- ▀ █ ▀ ▀
- ▀
-</pre>
-</a>
-<div id="navigation">
-<a href="https://example.org/">Home</a> -
-<a href="https://codeberg.org/">Repos</a> -
-<a href="https://example.org/about.html">About</a>
-</div>
-</div>
-<h1>This is a very interesting article about stamps</h1>
-
-<p>Here is a picture of some cool stamps</p>
-
-<p><img src="assets/stamps.webp" alt="" title="" /></p>
-
-<p>Thank you for reading my nice article.</p>
-</body>
-</html>
diff --git a/example/dst/articles/another-interesting-article/index.html b/example/dst/articles/another-interesting-article/index.html
deleted file mode 100644
index 010c0f1..0000000
--- a/example/dst/articles/another-interesting-article/index.html
+++ /dev/null
@@ -1,37 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <link rel="icon" type="image/png" href="https://example.org/favicon.png">
- <link rel="stylesheet" href="style.css">
- <title>Example</title>
-</head>
-<body>
-<div class="container">
-<a id="header" href="https://example.org">
-<pre>
-
-▄███▄ ▄ ██ █▀▄▀█ █ ▄▄ █ ▄███▄
-█▀ ▀ ▀▄ █ █ █ █ █ █ █ █ █ █▀ ▀
-██▄▄ █ ▀ █▄▄█ █ ▄ █ █▀▀▀ █ ██▄▄
-█▄ ▄▀ ▄ █ █ █ █ █ █ ███▄ █▄ ▄▀
-▀███▀ █ ▀▄ █ █ █ ▀ ▀███▀
- ▀ █ ▀ ▀
- ▀
-</pre>
-</a>
-<div id="navigation">
-<a href="https://example.org/">Home</a> -
-<a href="https://codeberg.org/">Repos</a> -
-<a href="https://example.org/about.html">About</a>
-</div>
-</div>
-<h1>I love trains</h1>
-
-<p>Aren't Japanese trains great? I particularly like the boxy ones. Here is a picture of a train:</p>
-
-<p><img src="assets/japanese-train.webp" alt="" title="" /></p>
-
-<p>Thank you for looking at this train</p>
-</body>
-</html>
diff --git a/example/dst/articles/article3.html b/example/dst/articles/article3.html
deleted file mode 100644
index 75783b7..0000000
--- a/example/dst/articles/article3.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <link rel="icon" type="image/png" href="https://example.org/favicon.png">
- <link rel="stylesheet" href="style.css">
- <title>Example</title>
-</head>
-<body>
-<div class="container">
-<a id="header" href="https://example.org">
-<pre>
-
-▄███▄ ▄ ██ █▀▄▀█ █ ▄▄ █ ▄███▄
-█▀ ▀ ▀▄ █ █ █ █ █ █ █ █ █ █▀ ▀
-██▄▄ █ ▀ █▄▄█ █ ▄ █ █▀▀▀ █ ██▄▄
-█▄ ▄▀ ▄ █ █ █ █ █ █ ███▄ █▄ ▄▀
-▀███▀ █ ▀▄ █ █ █ ▀ ▀███▀
- ▀ █ ▀ ▀
- ▀
-</pre>
-</a>
-<div id="navigation">
-<a href="https://example.org/">Home</a> -
-<a href="https://codeberg.org/">Repos</a> -
-<a href="https://example.org/about.html">About</a>
-</div>
-</div>
-<h1>Article 3</h1>
-
-<p>Wow another one</p>
-</body>
-</html>
diff --git a/example/dst/index.html b/example/dst/index.html
deleted file mode 100644
index 681fec9..0000000
--- a/example/dst/index.html
+++ /dev/null
@@ -1,41 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <link rel="icon" type="image/png" href="https://example.org/favicon.png">
- <link rel="stylesheet" href="style.css">
- <title>Example</title>
-</head>
-<body>
-<div class="container">
-<a id="header" href="https://example.org">
-<pre>
-
-▄███▄ ▄ ██ █▀▄▀█ █ ▄▄ █ ▄███▄
-█▀ ▀ ▀▄ █ █ █ █ █ █ █ █ █ █▀ ▀
-██▄▄ █ ▀ █▄▄█ █ ▄ █ █▀▀▀ █ ██▄▄
-█▄ ▄▀ ▄ █ █ █ █ █ █ ███▄ █▄ ▄▀
-▀███▀ █ ▀▄ █ █ █ ▀ ▀███▀
- ▀ █ ▀ ▀
- ▀
-</pre>
-</a>
-<div id="navigation">
-<a href="https://example.org/">Home</a> -
-<a href="https://codeberg.org/">Repos</a> -
-<a href="https://example.org/about.html">About</a>
-</div>
-</div>
-<h1>Articles</h1>
-<ul>
-<li>2024-10-04: <a href="https://example.org/articles/an-interesting-article/">This is a very interesting article about stamps</a></li>
-<li>2024-09-10: <a href="https://example.org/articles/another-interesting-article/">I love trains</a></li>
-<li>2023-10-08: <a href="https://example.org/articles/article3.html">This is a third article!</a></li>
-</ul>
-<h1>Lists</h1>
-<ul>
-<li>2024-07-12: <a href="https://example.org/lists/board-games.html">Board games</a></li>
-<li>2022-06-05: <a href="https://example.org/lists/movies.html">Movies</a></li>
-</ul>
-</body>
-</html>
diff --git a/example/src/_header.html b/example/src/_header.html
deleted file mode 100644
index a0923f4..0000000
--- a/example/src/_header.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <link rel="icon" type="image/png" href="https://example.org/favicon.png">
- <link rel="stylesheet" href="style.css">
- <title>Example</title>
-</head>
-<body>
-<div class="container">
-<a id="header" href="https://example.org">
-<pre>
-
-▄███▄ ▄ ██ █▀▄▀█ █ ▄▄ █ ▄███▄
-█▀ ▀ ▀▄ █ █ █ █ █ █ █ █ █ █▀ ▀
-██▄▄ █ ▀ █▄▄█ █ ▄ █ █▀▀▀ █ ██▄▄
-█▄ ▄▀ ▄ █ █ █ █ █ █ ███▄ █▄ ▄▀
-▀███▀ █ ▀▄ █ █ █ ▀ ▀███▀
- ▀ █ ▀ ▀
- ▀
-</pre>
-</a>
-<div id="navigation">
-<a href="https://example.org/">Home</a> -
-<a href="https://codeberg.org/">Repos</a> -
-<a href="https://example.org/about.html">About</a>
-</div>
-</div>
diff --git a/ssg-blog b/ssg-blog
index 0e1418c..3c33dbe 100755
--- a/ssg-blog
+++ b/ssg-blog
@@ -40,15 +40,15 @@ main() {
# files
- h_file="$src/_header.html"
- f_file="$src/_footer.html"
- test -f "$f_file" && FOOTER=$(cat "$f_file") && export FOOTER
- test -f "$h_file" && HEADER=$(cat "$h_file") && export HEADER
+ header_file="$src/_header.html"
+ footer_file="$src/_footer.html"
+ test -f "$footer_file" && FOOTER=$(cat "$footer_file") && export FOOTER
+ test -f "$header_file" && HEADER=$(cat "$header_file") && export HEADER
list_dirs "$src" |
(cd "$src" && cpio -pdu "$dst")
- fs=$(
+ files=$(
if test -f "$dst/.files"; then
list_affected_files "$src" "$dst/.files"
else
@@ -56,40 +56,39 @@ main() {
fi
)
- if test -n "$fs"; then
- echo "$fs" | tee "$dst/.files"
+ if test -n "$files"; then
+ echo "$files" | tee "$dst/.files"
- if echo "$fs" | grep -q '\.md$'; then
- if test -x "$(which lowdown 2>/dev/null)"; then
- echo "$fs" | grep '\.md$' |
- render_md_files_lowdown "$src" "$dst"
+ if echo "$files" | grep -q '\.md$'; then
+ if command -v lowdown >/dev/null 2>&1; then
+ md_cmd="lowdown --html-no-escapehtml --html-no-skiphtml --parse-no-metadata --parse-no-autolink"
+ elif command -v Markdown.pl >/dev/null 2>&1; then
+ md_cmd="Markdown.pl"
else
- if test -x "$(which Markdown.pl 2>/dev/null)"; then
- echo "$fs" | grep '\.md$' |
- render_md_files_Markdown_pl "$src" "$dst"
- else
- echo "couldn't find lowdown nor Markdown.pl"
- exit 3
- fi
+ echo "couldn't find lowdown nor Markdown.pl"
+ exit 3
fi
+ echo "$files" | grep '\.md$' |
+ render_md_files "$src" "$dst" "$md_cmd"
fi
- echo "$fs" | grep '\.html$' |
+ echo "$files" | grep '\.html$' |
render_html_files "$src" "$dst"
- echo "$fs" | grep -Ev '\.md$|\.html$' |
+ echo "$files" | grep -Ev '\.md$|\.html$' |
(cd "$src" && cpio -pu "$dst")
fi
printf '[ssg] ' >&2
- print_status 'file, ' 'files, ' "$fs" >&2
-
- #index
+ print_status 'file, ' 'files, ' "$files" >&2
+ # index
render_index
- # sitemap
+ # rss
+ render_rss
+ # sitemap
date=$(date +%Y-%m-%d)
urls=$(list_pages "$src")
@@ -164,31 +163,24 @@ list_affected_files() {
fi
}
-render_html_files() {
- while read -r f; do
- render_html_file <"$1/$f" >"$2/$f"
- done
+get_frontmatter_field() {
+ sed -n '/^'"$2"': /s/^'"$2"': //p' "$1" | head -n 1
}
-render_md_files_lowdown() {
+render_md_files() {
while read -r f; do
- title=$(sed -n '/^title: /s/^title: //p' "$1/$f" | head -n 1)
+ title=$(get_frontmatter_field "$1/$f" "title")
content=$(sed '1 { /^---/ { :a N; /\n---/! ba; d} }' "$1/$f")
- html_content=$(echo "$content" | lowdown --html-no-escapehtml --html-no-skiphtml --parse-no-metadata --parse-no-autolink)
+ html_content=$(echo "$content" | $3)
echo "$HEADER" | sed "s|<title>.*</title>|<title>$title</title>|" > "$2/${f%\.md}.html"
echo "$html_content" >> "$2/${f%\.md}.html"
echo "$FOOTER" >> "$2/${f%\.md}.html"
done
}
-render_md_files_Markdown_pl() {
+render_html_files() {
while read -r f; do
- title=$(sed -n '/^title: /s/^title: //p' "$1/$f" | head -n 1)
- content=$(sed '1 { /^---/ { :a N; /\n---/! ba; d} }' "$1/$f")
- html_content=$(echo "$content" | Markdown.pl)
- echo "$HEADER" | sed "s|<title>.*</title>|<title>$title</title>|" > "$2/${f%\.md}.html"
- echo "$html_content" >> "$2/${f%\.md}.html"
- echo "$FOOTER" >> "$2/${f%\.md}.html"
+ render_html_file <"$1/$f" >"$2/$f"
done
}
@@ -203,47 +195,96 @@ render_html_file() {
list_pages() {
e="\\( -name '*.html' -o -name '*.md' \\)"
cd "$1" && eval "find . -type f ! -path '*/.*' ! -path '*/_*' $IGNORE $e" |
+ while read -r f; do
+ case "$f" in
+ *.md)
+ test "$(get_frontmatter_field "$1/$f" "publish")" != "false" || continue
+ ;;
+ esac
+ echo "$f"
+ done |
sed 's#^./##;s#.md$#.html#;s#/index.html$#/#'
}
-render_index() {
- output="$dst/index.html"
- echo "$HEADER" > "$output"
-
- find "$src" -mindepth 1 -maxdepth 1 -type d ! -path "*/.*" | sort |
+list_articles() {
+ find "$1" -mindepth 1 -maxdepth 1 -type d ! -path "*/.*" | sort |
while read -r category_dir; do
category=$(basename "$category_dir")
-
find "$category_dir" -type f \( -name "*.md" -o -name "index.md" \) ! -path "*/.*" |
while read -r article; do
- publish=$(sed -n '/^publish: /s/^publish: //p' "$article" | head -n 1)
- title=$(sed -n '/^title: /s/title: //p' "$article" | head -n 1)
- date=$(sed -n '/^date: /s/date: //p' "$article" | head -n 1)
- if [ "$publish" = "false" ] || [ -z "$date" ]; then
- continue
+ test "$(get_frontmatter_field "$article" "publish")" != "false" || continue
+ date=$(get_frontmatter_field "$article" "date")
+ test -n "$date" || continue
+ title=$(get_frontmatter_field "$article" "title")
+ url="${article#"$1"}"
+ url="${url%.md}.html"
+ if [ "${url##*/}" = "index.html" ]; then
+ url="${url%/index.html}/"
fi
- article_url="${article#"$src"}"
- article_url="${article_url%.md}.html"
- if [ "${article_url##*/}" = "index.html" ]; then
- article_url="${article_url%/index.html}/"
- fi
- article_url="${article_url#/}"
- echo "$date|$title|$article_url" >> "/tmp/articles_$category.txt"
+ url="${url#/}"
+ echo "$category|$date|$title|$url"
done
+ done
+}
- if [ -f "/tmp/articles_$category.txt" ]; then
- echo "<h1>$(echo "$category" | sed -E 's/_/ /g; s/(^|[ ])([a-z])/\1\U\2/g')</h1>" >> "$output"
- sort -r "/tmp/articles_$category.txt" |
- while IFS='|' read -r date title url; do
- echo "$date: <a href=\"$base_url/$url\">$title</a><br />" >> "$output"
- done
- rm "/tmp/articles_$category.txt"
+render_index() {
+ output="$dst/index.html"
+ echo "$HEADER" > "$output"
+
+ last_category=""
+ list_articles "$src" | sort -t'|' -k1,1 -k2,2r |
+ while IFS='|' read -r category date title url; do
+ if [ "$category" != "$last_category" ]; then
+ display_category=$(echo "$category" | sed 's/_/ /g' | awk '{for(i=1;i<=NF;i++){s=$i;$i=toupper(substr(s,1,1)) substr(s,2)}; print}')
+ echo "<h1>$display_category</h1>" >> "$output"
+ last_category="$category"
fi
+ echo "$date: <a href=\"$base_url/$url\">$title</a><br />" >> "$output"
done
echo "$FOOTER" >> "$output"
}
+xml_escape() {
+ sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g'
+}
+
+rfc822_date() {
+ if d=$(date -d "$1" -u +"%a, %d %b %Y %H:%M:%S GMT" 2>/dev/null); then
+ echo "$d"
+ else
+ echo "$1"
+ fi
+}
+
+render_rss() {
+ list_articles "$src" | sort -t'|' -k2,2r |
+ {
+ echo '<?xml version="1.0" encoding="UTF-8"?>'
+ echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'
+ echo '<channel>'
+ echo "<title>Blog</title>"
+ echo "<link>$base_url/</link>"
+ echo "<description>Blog</description>"
+ echo "<atom:link href=\"$base_url/rss.xml\" rel=\"self\" type=\"application/rss+xml\"/>"
+
+ while IFS='|' read -r category date title url; do
+ escaped_title=$(echo "$title" | xml_escape)
+ escaped_url=$(echo "$url" | xml_escape)
+ pub_date=$(rfc822_date "$date")
+ echo '<item>'
+ echo "<title>$escaped_title</title>"
+ echo "<link>$base_url/$escaped_url</link>"
+ echo "<guid>$base_url/$escaped_url</guid>"
+ echo "<pubDate>$pub_date</pubDate>"
+ echo '</item>'
+ done
+
+ echo '</channel>'
+ echo '</rss>'
+ } > "$dst/rss.xml"
+}
+
render_sitemap() {
urls="$1"
base_url="$2"