From 64d24fa8eb52ae9de6143b6823a96ec9e06d09da Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 1 Dec 2019 21:46:39 -0800 Subject: [PATCH] WIP: port static markdown files in public root --- Readme.md | 26 ++++++++++++++-- .../Sources/SiteGenerator/Model/Post.swift | 30 +++++++++++++++++++ Tests/test-styles/in/templates/site.html | 2 +- public/about.md | 4 +++ templates/samhuri.net.html | 4 +-- 5 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 SiteGenerator/Sources/SiteGenerator/Model/Post.swift diff --git a/Readme.md b/Readme.md index 64f3e5d..b64e923 100644 --- a/Readme.md +++ b/Readme.md @@ -23,18 +23,32 @@ Execution, trying TDD for the first time: - [x] Add support for site styles - - [ ] Add support for page styles + - [x] Add support for page styles - [x] Add support for site scripts - - [ ] Add support for page scripts + - [x] Add support for page scripts - [x] Add support for CSS files - [x] Transform LESS into CSS + - [ ] Migrate static pages to the new site generator + + - [ ] About + + - [ ] 404 / missing + + - [ ] cv + + - [ ] check and delete _data.json + - [ ] Migrate projects to the new site generator + - [ ] Migrate projects page + + - [ ] Migrate project page + - [ ] Migrate posts to markdown with headers somehow - [ ] Define the new format, probably with a folder for each year of posts since I don't write very much @@ -43,6 +57,14 @@ Execution, trying TDD for the first time: - [ ] Migrate posts + - [ ] Migrate year indexes + + - [ ] Migrate month indexes + + - [ ] Migrate index / recent posts + + - [ ] Migrate archive + - [ ] Add a link to the code for samhuri.net somewhere ... so meta (about page?) - [ ] Generate RSS feed (ditch mustache templates) diff --git a/SiteGenerator/Sources/SiteGenerator/Model/Post.swift b/SiteGenerator/Sources/SiteGenerator/Model/Post.swift new file mode 100644 index 0000000..afef3f0 --- /dev/null +++ b/SiteGenerator/Sources/SiteGenerator/Model/Post.swift @@ -0,0 +1,30 @@ +// +// Post.swift +// SiteGenerator +// +// Created by Sami Samhuri on 2019-12-01. +// + +import Foundation + +struct Post { + let date: Date + let formattedDate: String + let title: String + let slug: String + let author: String + let tags: [String] + let body: String + + var path: String { + let dateComponents = Calendar.current.dateComponents([.year], from: date) + let year = dateComponents.year! + let month = dateComponents.month! + return "/" + [ + "posts", + "\(year)", + "\(month)", + "\(slug)", + ].joined(separator: "/") + } +} diff --git a/Tests/test-styles/in/templates/site.html b/Tests/test-styles/in/templates/site.html index 8e140a6..1cac9e4 100644 --- a/Tests/test-styles/in/templates/site.html +++ b/Tests/test-styles/in/templates/site.html @@ -2,7 +2,7 @@ {{ site.title }} -{% for style in allStyles %} +{% for style in styles %} {% endfor %} diff --git a/public/about.md b/public/about.md index 5d7bafa..c2104e9 100644 --- a/public/about.md +++ b/public/about.md @@ -1,3 +1,7 @@ +--- +Title: About me +--- + I'm Sami Samhuri, a software developer and general technology geek. Sometimes I write my thoughts and post my projects here. I moved to [Victoria, BC][vic] in 2003 to study computer science at the [University of Victoria][uvic], and diff --git a/templates/samhuri.net.html b/templates/samhuri.net.html index 0a956ef..072cd2e 100644 --- a/templates/samhuri.net.html +++ b/templates/samhuri.net.html @@ -15,7 +15,7 @@ -{% for style in allStyles %} +{% for style in styles %} {% endfor %} @@ -88,7 +88,7 @@ })(); -{% for script in allScripts %} +{% for script in scripts %} {% endfor %}