diff --git a/SiteGenerator/Sources/SiteGenerator/Posts/PostsPlugin.swift b/SiteGenerator/Sources/SiteGenerator/Posts/PostsPlugin.swift index 415b670..829b1ef 100644 --- a/SiteGenerator/Sources/SiteGenerator/Posts/PostsPlugin.swift +++ b/SiteGenerator/Sources/SiteGenerator/Posts/PostsPlugin.swift @@ -128,17 +128,12 @@ final class PostsPlugin: Plugin { try fileManager.createDirectory(at: monthDir, withIntermediateDirectories: true, attributes: nil) let filename = "\(post.slug).html" let postURL = monthDir.appendingPathComponent(filename) - let templateName = self.templateName(for: post) let bodyHTML = markdownParser.html(from: post.bodyMarkdown) let renderedPost = RenderedPost(post: post, body: bodyHTML) - let postHTML = try templateRenderer.renderTemplate(name: templateName, context: ["post": renderedPost.dictionary]) + let postHTML = try templateRenderer.renderTemplate(name: "post", context: ["post": renderedPost.dictionary]) try postHTML.write(to: postURL, atomically: true, encoding: .utf8) } - private func templateName(for post: Post) -> String { - post.isLink ? "post-link" : "post-text" - } - private func enumerateMarkdownFiles(directory: URL) throws -> [URL] { return try fileManager.contentsOfDirectory(atPath: directory.path).flatMap { (filename: String) -> [URL] in let fileURL = directory.appendingPathComponent(filename) diff --git a/templates/misc-PROJECT??.html b/templates/misc-PROJECT??.html deleted file mode 100644 index 3f3c94c..0000000 --- a/templates/misc-PROJECT??.html +++ /dev/null @@ -1,34 +0,0 @@ -HANDLED {% if post.link %} -%> -
-
-

→ <%= post.title %>

- - -
- <%- yield %> -
-
-

-
-HANDLED <% } else if (typeof date != 'undefined' && date !== null) { -%> -
-
-

<%= title %>

- -
- <%- yield %> -
-
-

-
-WTF IS THIS?? MUST BE PROJECTS! <% } else if (typeof title != 'undefined' && title !== null) { -%> -
-

<%= title %>

- <%- yield %> -
-
-

-
-HANDLED <% } else { -%> - <%- yield %> - <% } -%> diff --git a/templates/page.html b/templates/page.html index 2059ad5..7a4ce4a 100644 --- a/templates/page.html +++ b/templates/page.html @@ -1,4 +1,5 @@ {% extends "samhuri.net.html" %} + {% block body %}

{{ page.title }}

diff --git a/templates/post-link.html b/templates/partial-post-link.html similarity index 69% rename from templates/post-link.html rename to templates/partial-post-link.html index 42e5359..7661a61 100644 --- a/templates/post-link.html +++ b/templates/partial-post-link.html @@ -1,15 +1,11 @@ -{% extends "samhuri.net.html" %} - -{% block body %}

→ {{ post.title }}

- +
{{ post.body }}

-{% endblock %} diff --git a/templates/post-text.html b/templates/partial-post-text.html similarity index 80% rename from templates/post-text.html rename to templates/partial-post-text.html index 712c671..6e0fdaf 100644 --- a/templates/post-text.html +++ b/templates/partial-post-text.html @@ -1,6 +1,3 @@ -{% extends "samhuri.net.html" %} - -{% block body %}

{{ post.title }}

@@ -11,4 +8,3 @@

-{% endblock %} diff --git a/templates/partial-post.html b/templates/partial-post.html new file mode 100644 index 0000000..92e36c0 --- /dev/null +++ b/templates/partial-post.html @@ -0,0 +1,5 @@ +{% if post.isLink %} + {% include "partial-post-link.html" %} +{% else %} + {% include "partial-post-text.html" %} +{% endif %} diff --git a/templates/post.html b/templates/post.html new file mode 100644 index 0000000..a6491fd --- /dev/null +++ b/templates/post.html @@ -0,0 +1,5 @@ +{% extends "samhuri.net.html" %} + +{% block body %} +{% include "partial-post.html" %} +{% endblock %} diff --git a/templates/posts-month.html b/templates/posts-month.html index bb70580..6de6e03 100644 --- a/templates/posts-month.html +++ b/templates/posts-month.html @@ -1,24 +1,7 @@ {% extends "samhuri.net.html" %} {% block body %} -{% for post in posts %} - -
-

-
- -{% endfor %} + {% for post in posts %} + {% include "partial-post.html" post %} + {% endfor %} {% endblock %} diff --git a/templates/recent-posts.html b/templates/recent-posts.html index 4afc17d..d122c34 100644 --- a/templates/recent-posts.html +++ b/templates/recent-posts.html @@ -1,38 +1,9 @@ {% extends "samhuri.net.html" %} + {% block body %}
-<% var posts = public._data.posts -%> -<% for (var i in posts) { -%> - - <% var post = posts[i] -%> - - <% if (post.link) { -%> - - - - <% } else { -%> - - - - <% } -%> - -
-

-
- -<% } -%> + {% for post in recentPosts %} + {% include "partial-post.html" post %} + {% endfor %}
{% endblock %}