mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-04-27 14:57:40 +00:00
Hide .html extensions on all pages by default
This uses the same old page-title/index.html trick that was used before.
This commit is contained in:
parent
d184ed06fa
commit
652d192560
30 changed files with 564 additions and 18 deletions
|
|
@ -25,7 +25,7 @@ final class PostWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
func urlPathForPost(date: Date, slug: String) -> String {
|
func urlPathForPost(date: Date, slug: String) -> String {
|
||||||
urlPath(year: date.year, month: Month(date.month)).appending("/\(slug).html")
|
urlPath(year: date.year, month: Month(date.month)).appending("/\(slug)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ extension PostWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func filePath(date: Date, slug: String) -> String {
|
private func filePath(date: Date, slug: String) -> String {
|
||||||
"/\(date.year)/\(Month(date.month).padded)/\(slug).html"
|
"/\(date.year)/\(Month(date.month).padded)/\(slug)/index.html"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@ private struct Projects: Codable {
|
||||||
|
|
||||||
final class ProjectsPlugin: Plugin {
|
final class ProjectsPlugin: Plugin {
|
||||||
let fileManager: FileManager = .default
|
let fileManager: FileManager = .default
|
||||||
let path: String
|
let outputPath: String
|
||||||
|
|
||||||
var projects: [Project] = []
|
var projects: [Project] = []
|
||||||
var sourceURL: URL!
|
var sourceURL: URL!
|
||||||
|
|
||||||
init(path: String = "projects") {
|
init(outputPath: String = "projects") {
|
||||||
self.path = path
|
self.outputPath = outputPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func setUp(sourceURL: URL) throws {
|
func setUp(sourceURL: URL) throws {
|
||||||
|
|
@ -33,7 +33,7 @@ final class ProjectsPlugin: Plugin {
|
||||||
let projectsURL = sourceURL.appendingPathComponent("projects.json")
|
let projectsURL = sourceURL.appendingPathComponent("projects.json")
|
||||||
if fileManager.fileExists(atPath: projectsURL.path) {
|
if fileManager.fileExists(atPath: projectsURL.path) {
|
||||||
self.projects = try Projects.decode(from: projectsURL).projects.map { project in
|
self.projects = try Projects.decode(from: projectsURL).projects.map { project in
|
||||||
Project(title: project.title, description: project.description, path: "/\(path)/\(project.title).html")
|
Project(title: project.title, description: project.description, path: "/\(outputPath)/\(project.title)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +43,7 @@ final class ProjectsPlugin: Plugin {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let projectsDir = targetURL.appendingPathComponent(path)
|
let projectsDir = targetURL.appendingPathComponent(outputPath)
|
||||||
try fileManager.createDirectory(at: projectsDir, withIntermediateDirectories: true, attributes: nil)
|
try fileManager.createDirectory(at: projectsDir, withIntermediateDirectories: true, attributes: nil)
|
||||||
let projectsURL = projectsDir.appendingPathComponent("index.html")
|
let projectsURL = projectsDir.appendingPathComponent("index.html")
|
||||||
let projectsHTML = try templateRenderer.renderTemplate(name: "projects", context: [
|
let projectsHTML = try templateRenderer.renderTemplate(name: "projects", context: [
|
||||||
|
|
@ -53,12 +53,12 @@ final class ProjectsPlugin: Plugin {
|
||||||
try projectsHTML.write(to: projectsURL, atomically: true, encoding: .utf8)
|
try projectsHTML.write(to: projectsURL, atomically: true, encoding: .utf8)
|
||||||
|
|
||||||
for project in projects {
|
for project in projects {
|
||||||
let filename = "\(project.title).html"
|
let projectURL = projectsDir.appendingPathComponent("\(project.title)/index.html")
|
||||||
let projectURL = projectsDir.appendingPathComponent(filename)
|
|
||||||
let projectHTML = try templateRenderer.renderTemplate(name: "project", context: [
|
let projectHTML = try templateRenderer.renderTemplate(name: "project", context: [
|
||||||
"title": "\(project.title)",
|
"title": "\(project.title)",
|
||||||
"project": project,
|
"project": project,
|
||||||
])
|
])
|
||||||
|
try fileManager.createDirectory(at: projectURL.deletingLastPathComponent(), withIntermediateDirectories: true, attributes: nil)
|
||||||
try projectHTML.write(to: projectURL, atomically: true, encoding: .utf8)
|
try projectHTML.write(to: projectURL, atomically: true, encoding: .utf8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import Foundation
|
||||||
import Ink
|
import Ink
|
||||||
|
|
||||||
public final class MarkdownRenderer: Renderer {
|
public final class MarkdownRenderer: Renderer {
|
||||||
|
let fileManager: FileManager = .default
|
||||||
let markdownParser = MarkdownParser()
|
let markdownParser = MarkdownParser()
|
||||||
|
|
||||||
public func canRenderFile(named filename: String, withExtension ext: String) -> Bool {
|
public func canRenderFile(named filename: String, withExtension ext: String) -> Bool {
|
||||||
|
|
@ -17,13 +18,21 @@ public final class MarkdownRenderer: Renderer {
|
||||||
|
|
||||||
/// Parse Markdown and render it as HTML, running it through a Stencil template.
|
/// Parse Markdown and render it as HTML, running it through a Stencil template.
|
||||||
public func render(fileURL: URL, targetDir: URL, templateRenderer: TemplateRenderer) throws {
|
public func render(fileURL: URL, targetDir: URL, templateRenderer: TemplateRenderer) throws {
|
||||||
let mdFilename = fileURL.lastPathComponent
|
|
||||||
let htmlFilename = mdFilename.replacingOccurrences(of: ".md", with: ".html")
|
|
||||||
let htmlURL = targetDir.appendingPathComponent(htmlFilename)
|
|
||||||
let bodyMarkdown = try String(contentsOf: fileURL, encoding: .utf8)
|
let bodyMarkdown = try String(contentsOf: fileURL, encoding: .utf8)
|
||||||
let bodyHTML = markdownParser.html(from: bodyMarkdown).trimmingCharacters(in: .whitespacesAndNewlines)
|
let bodyHTML = markdownParser.html(from: bodyMarkdown).trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
let metadata = try markdownMetadata(from: fileURL)
|
let metadata = try markdownMetadata(from: fileURL)
|
||||||
let pageHTML = try templateRenderer.renderPage(bodyHTML: bodyHTML, metadata: metadata)
|
let pageHTML = try templateRenderer.renderPage(bodyHTML: bodyHTML, metadata: metadata)
|
||||||
|
|
||||||
|
let mdFilename = fileURL.lastPathComponent
|
||||||
|
let htmlPath: String
|
||||||
|
if metadata["Hide extension"]?.lowercased() == "no" || mdFilename == "index.md" {
|
||||||
|
htmlPath = mdFilename.replacingOccurrences(of: ".md", with: ".html")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
htmlPath = mdFilename.replacingOccurrences(of: ".md", with: "/index.html")
|
||||||
|
}
|
||||||
|
let htmlURL = targetDir.appendingPathComponent(htmlPath)
|
||||||
|
try fileManager.createDirectory(at: htmlURL.deletingLastPathComponent(), withIntermediateDirectories: true, attributes: nil)
|
||||||
try pageHTML.write(to: htmlURL, atomically: true, encoding: .utf8)
|
try pageHTML.write(to: htmlURL, atomically: true, encoding: .utf8)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
62
Tests/test-posts/expected/index.html
Normal file
62
Tests/test-posts/expected/index.html
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||||
|
|
||||||
|
|
||||||
|
<title>gonzo journalism: gonzo journalism</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<div class="title">
|
||||||
|
<h1><a href="/">gonzo journalism</a></h1>
|
||||||
|
<br>
|
||||||
|
<h4>By <a href="/about">Hunter S. Thompson</a></h4>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
|
||||||
|
<h2>→ <a href="https://placekitten.com">Cats</a></h2>
|
||||||
|
|
||||||
|
<time>18th December, 2019</time>
|
||||||
|
<a class="permalink" href="/posts/2019/12/cats">∞</a>
|
||||||
|
</header>
|
||||||
|
<p>Cats are neat. Look at these kittens!</p>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
|
||||||
|
<h2><a href="/posts/2019/12/fear-and-loathing">Fear and Loathing in Las Vegas</a></h2>
|
||||||
|
|
||||||
|
<time>9th December, 2019</time>
|
||||||
|
<a class="permalink" href="/posts/2019/12/fear-and-loathing">∞</a>
|
||||||
|
</header>
|
||||||
|
<p>We were somewhere around Barstow on the edge of the desert when the drugs began to take hold.</p>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="container">
|
||||||
|
© 2006 - 2019 <a href="/about">Hunter S. Thompson</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
44
Tests/test-posts/expected/posts/2019/12/cats/index.html
Normal file
44
Tests/test-posts/expected/posts/2019/12/cats/index.html
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||||
|
|
||||||
|
|
||||||
|
<title>gonzo journalism: Cats</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<div class="title">
|
||||||
|
<h1><a href="/">gonzo journalism</a></h1>
|
||||||
|
<br>
|
||||||
|
<h4>By <a href="/about">Hunter S. Thompson</a></h4>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
|
||||||
|
<h2>→ <a href="https://placekitten.com">Cats</a></h2>
|
||||||
|
|
||||||
|
<time>18th December, 2019</time>
|
||||||
|
<a class="permalink" href="/posts/2019/12/cats">∞</a>
|
||||||
|
</header>
|
||||||
|
<p>Cats are neat. Look at these kittens!</p>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="container">
|
||||||
|
© 2006 - 2019 <a href="/about">Hunter S. Thompson</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||||
|
|
||||||
|
|
||||||
|
<title>gonzo journalism: Fear and Loathing in Las Vegas</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<div class="title">
|
||||||
|
<h1><a href="/">gonzo journalism</a></h1>
|
||||||
|
<br>
|
||||||
|
<h4>By <a href="/about">Hunter S. Thompson</a></h4>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
|
||||||
|
<h2><a href="/posts/2019/12/fear-and-loathing">Fear and Loathing in Las Vegas</a></h2>
|
||||||
|
|
||||||
|
<time>9th December, 2019</time>
|
||||||
|
<a class="permalink" href="/posts/2019/12/fear-and-loathing">∞</a>
|
||||||
|
</header>
|
||||||
|
<p>We were somewhere around Barstow on the edge of the desert when the drugs began to take hold.</p>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="container">
|
||||||
|
© 2006 - 2019 <a href="/about">Hunter S. Thompson</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
64
Tests/test-posts/expected/posts/2019/12/index.html
Normal file
64
Tests/test-posts/expected/posts/2019/12/index.html
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||||
|
|
||||||
|
|
||||||
|
<title>gonzo journalism: December 2019</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<div class="title">
|
||||||
|
<h1><a href="/">gonzo journalism</a></h1>
|
||||||
|
<br>
|
||||||
|
<h4>By <a href="/about">Hunter S. Thompson</a></h4>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="month">
|
||||||
|
<h1>December 2019</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
|
||||||
|
<h2>→ <a href="https://placekitten.com">Cats</a></h2>
|
||||||
|
|
||||||
|
<time>18th December, 2019</time>
|
||||||
|
<a class="permalink" href="/posts/2019/12/cats">∞</a>
|
||||||
|
</header>
|
||||||
|
<p>Cats are neat. Look at these kittens!</p>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
|
||||||
|
<h2><a href="/posts/2019/12/fear-and-loathing">Fear and Loathing in Las Vegas</a></h2>
|
||||||
|
|
||||||
|
<time>9th December, 2019</time>
|
||||||
|
<a class="permalink" href="/posts/2019/12/fear-and-loathing">∞</a>
|
||||||
|
</header>
|
||||||
|
<p>We were somewhere around Barstow on the edge of the desert when the drugs began to take hold.</p>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="container">
|
||||||
|
© 2006 - 2019 <a href="/about">Hunter S. Thompson</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
67
Tests/test-posts/expected/posts/2019/index.html
Normal file
67
Tests/test-posts/expected/posts/2019/index.html
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||||
|
|
||||||
|
|
||||||
|
<title>gonzo journalism: 2019</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<div class="title">
|
||||||
|
<h1><a href="/">gonzo journalism</a></h1>
|
||||||
|
<br>
|
||||||
|
<h4>By <a href="/about">Hunter S. Thompson</a></h4>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="year">
|
||||||
|
<h1>2019</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>
|
||||||
|
<a href="/posts/2019/12">December</a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<ul class="archive">
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<a href="https://placekitten.com">→ Cats</a>
|
||||||
|
|
||||||
|
<time>18 Dec</time>
|
||||||
|
|
||||||
|
<a class="permalink" href="/posts/2019/12/cats">∞</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<a href="/posts/2019/12/fear-and-loathing">Fear and Loathing in Las Vegas</a>
|
||||||
|
|
||||||
|
<time>9 Dec</time>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="container">
|
||||||
|
© 2006 - 2019 <a href="/about">Hunter S. Thompson</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
71
Tests/test-posts/expected/posts/index.html
Normal file
71
Tests/test-posts/expected/posts/index.html
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||||
|
|
||||||
|
|
||||||
|
<title>gonzo journalism: Archive</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<div class="title">
|
||||||
|
<h1><a href="/">gonzo journalism</a></h1>
|
||||||
|
<br>
|
||||||
|
<h4>By <a href="/about">Hunter S. Thompson</a></h4>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Archive</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="year">
|
||||||
|
<h2><a href="/posts/2019">2019</a></h2>
|
||||||
|
|
||||||
|
|
||||||
|
<h3>
|
||||||
|
<a href="/posts/2019/12">December</a>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<ul class="archive">
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<a href="https://placekitten.com">→ Cats</a>
|
||||||
|
|
||||||
|
<time>18 Dec</time>
|
||||||
|
|
||||||
|
<a class="permalink" href="/posts/2019/12/cats">∞</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<a href="/posts/2019/12/fear-and-loathing">Fear and Loathing in Las Vegas</a>
|
||||||
|
|
||||||
|
<time>9 Dec</time>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="container">
|
||||||
|
© 2006 - 2019 <a href="/about">Hunter S. Thompson</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
10
Tests/test-posts/in/posts/2019/12/cats.md
Normal file
10
Tests/test-posts/in/posts/2019/12/cats.md
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
Title: Cats
|
||||||
|
Author: Sami Samhuri
|
||||||
|
Date: 18th December, 2019
|
||||||
|
Link: https://placekitten.com
|
||||||
|
Timestamp: 1576656168
|
||||||
|
Tags: cats
|
||||||
|
---
|
||||||
|
|
||||||
|
Cats are neat. Look at these kittens!
|
||||||
9
Tests/test-posts/in/posts/2019/12/fear-and-loathing.md
Normal file
9
Tests/test-posts/in/posts/2019/12/fear-and-loathing.md
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
Title: Fear and Loathing in Las Vegas
|
||||||
|
Author: Hunter S. Thompson
|
||||||
|
Date: 9th December, 2019
|
||||||
|
Timestamp: 1575964368
|
||||||
|
Tags: fear, loathing, las vegas
|
||||||
|
---
|
||||||
|
|
||||||
|
We were somewhere around Barstow on the edge of the desert when the drugs began to take hold.
|
||||||
5
Tests/test-posts/in/site.json
Normal file
5
Tests/test-posts/in/site.json
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"author": "Hunter S. Thompson",
|
||||||
|
"title": "gonzo journalism",
|
||||||
|
"url": "http://example.net"
|
||||||
|
}
|
||||||
12
Tests/test-posts/in/templates/partial-post.html
Normal file
12
Tests/test-posts/in/templates/partial-post.html
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
{% if post.isLink %}
|
||||||
|
<h2>→ <a href="{{ post.link }}">{{ post.title }}</a></h2>
|
||||||
|
{% else %}
|
||||||
|
<h2><a href="{{ post.path }}">{{ post.title }}</a></h2>
|
||||||
|
{% endif %}
|
||||||
|
<time>{{ post.formattedDate }}</time>
|
||||||
|
<a class="permalink" href="{{ post.path }}">∞</a>
|
||||||
|
</header>
|
||||||
|
{{ post.body }}
|
||||||
|
</article>
|
||||||
5
Tests/test-posts/in/templates/post.html
Normal file
5
Tests/test-posts/in/templates/post.html
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{% extends "site.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
{% include "partial-post.html" post %}
|
||||||
|
{% endblock %}
|
||||||
36
Tests/test-posts/in/templates/posts-archive.html
Normal file
36
Tests/test-posts/in/templates/posts-archive.html
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
{% extends "site.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<h1>{{ title }}</h1>
|
||||||
|
|
||||||
|
{% for year in years %}
|
||||||
|
<div class="year">
|
||||||
|
<h2><a href="{{ year.path }}">{{ year.title }}</a></h2>
|
||||||
|
|
||||||
|
{% for month in year.months %}
|
||||||
|
<h3>
|
||||||
|
<a href="{{ month.path }}">{{ month.name }}</a>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<ul class="archive">
|
||||||
|
{% for post in month.posts %}
|
||||||
|
<li>
|
||||||
|
{% if post.isLink %}
|
||||||
|
<a href="{{ post.link }}">→ {{ post.title }}</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{{ post.path }}">{{ post.title }}</a>
|
||||||
|
{% endif %}
|
||||||
|
<time>{{ post.day }} {{ month.abbreviation }}</time>
|
||||||
|
{% if post.isLink %}
|
||||||
|
<a class="permalink" href="{{ post.path }}">∞</a>
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
13
Tests/test-posts/in/templates/posts-month.html
Normal file
13
Tests/test-posts/in/templates/posts-month.html
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{% extends "site.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<div class="month">
|
||||||
|
<h1>{{ title }}</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% for post in posts %}
|
||||||
|
{% include "partial-post.html" post %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
32
Tests/test-posts/in/templates/posts-year.html
Normal file
32
Tests/test-posts/in/templates/posts-year.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
{% extends "site.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<div class="year">
|
||||||
|
<h1>{{ title }}</h1>
|
||||||
|
|
||||||
|
{% for month in months %}
|
||||||
|
<h2>
|
||||||
|
<a href="{{ month.path }}">{{ month.name }}</a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<ul class="archive">
|
||||||
|
{% for post in month.posts %}
|
||||||
|
<li>
|
||||||
|
{% if post.isLink %}
|
||||||
|
<a href="{{ post.link }}">→ {{ post.title }}</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{{ post.path }}">{{ post.title }}</a>
|
||||||
|
{% endif %}
|
||||||
|
<time>{{ post.day }} {{ month.abbreviation }}</time>
|
||||||
|
{% if post.isLink %}
|
||||||
|
<a class="permalink" href="{{ post.path }}">∞</a>
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
11
Tests/test-posts/in/templates/recent-posts.html
Normal file
11
Tests/test-posts/in/templates/recent-posts.html
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{% extends "site.html" %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
{% for post in recentPosts %}
|
||||||
|
{% include "partial-post.html" post %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
40
Tests/test-posts/in/templates/site.html
Normal file
40
Tests/test-posts/in/templates/site.html
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||||
|
|
||||||
|
{% if title %}
|
||||||
|
<title>{{ site.title }}: {{ title }}</title>
|
||||||
|
{% elif page.title %}
|
||||||
|
<title>{{ site.title }}: {{ page.title }}</title>
|
||||||
|
{% else %}
|
||||||
|
<title>{{ site.title }}</title>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for style in styles %}
|
||||||
|
<link rel="stylesheet" href="{{ style }}">
|
||||||
|
{% endfor %}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<div class="title">
|
||||||
|
<h1><a href="/">{{ site.title }}</a></h1>
|
||||||
|
<br>
|
||||||
|
<h4>By <a href="/about">{{ site.author }}</a></h4>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{% block body %}{{ body }}{% endblock %}
|
||||||
|
|
||||||
|
<footer class="container">
|
||||||
|
© 2006 - {{ currentYear }} <a href="/about">{{ site.author }}</a>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
{% for script in scripts %}
|
||||||
|
<script defer src="{{ script }}"></script>
|
||||||
|
{% endfor %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
|
||||||
<li><a href="/projects/linux.html">linux</a></li>
|
<li><a href="/projects/linux">linux</a></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
2
bin/test
2
bin/test
|
|
@ -4,6 +4,6 @@ set -e
|
||||||
|
|
||||||
for site in Tests/test-*; do
|
for site in Tests/test-*; do
|
||||||
bin/compile "$site/in" "$site/actual" # >/dev/null
|
bin/compile "$site/in" "$site/actual" # >/dev/null
|
||||||
diff -ru "$site/expected" "$site/actual"
|
diff -bru "$site/expected" "$site/actual"
|
||||||
rm -r "$site/actual"
|
rm -r "$site/actual"
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -1 +1,5 @@
|
||||||
|
---
|
||||||
|
Hide extension: no
|
||||||
|
---
|
||||||
|
|
||||||
<p align="center">four oh four</p>
|
<p align="center">four oh four</p>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
{% extends "samhuri.net.html" %}
|
{% extends "samhuri.net.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>{{ title }}</h1>
|
<h1>{{ title }}</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -8,4 +9,5 @@
|
||||||
{% for post in posts %}
|
{% for post in posts %}
|
||||||
{% include "partial-post.html" post %}
|
{% include "partial-post.html" post %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
{% for post in month.posts %}
|
{% for post in month.posts %}
|
||||||
<li>
|
<li>
|
||||||
{% if post.isLink %}
|
{% if post.isLink %}
|
||||||
<a href="{{ post.path }}">→ {{ post.title }}</a>
|
<a href="{{ post.link }}">→ {{ post.title }}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ post.path }}">{{ post.title }}</a>
|
<a href="{{ post.path }}">{{ post.title }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
@ -28,4 +28,5 @@
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
{% extends "samhuri.net.html" %}
|
{% extends "samhuri.net.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
<article class="container">
|
<article class="container">
|
||||||
<h1>Projects</h1>
|
<h1>Projects</h1>
|
||||||
|
|
||||||
|
|
@ -13,4 +15,5 @@
|
||||||
<div class="row clearfix">
|
<div class="row clearfix">
|
||||||
<p class="fin"><i class="fa fa-code"></i></p>
|
<p class="fin"><i class="fa fa-code"></i></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
{% extends "samhuri.net.html" %}
|
{% extends "samhuri.net.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
{% for post in recentPosts %}
|
{% for post in recentPosts %}
|
||||||
{% include "partial-post.html" post %}
|
{% include "partial-post.html" post %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue