From 91c316a3dad7288dc35eb98678887c747e0f455d Mon Sep 17 00:00:00 2001 From: Tim Stallard Date: Sat, 3 Sep 2016 17:47:02 +0100 Subject: [PATCH] Changed some code structure, added some elements + styling to blog views --- docpad.js | 12 ++++++--- src/documents/blog.html.ejs | 12 +++++---- .../blog/2016-04-11-tvheadend-vm.html.md | 1 - src/documents/styles.css.scss | 26 ++++++++++++++----- src/layouts/blogpost.html.ejs | 4 +-- src/layouts/contentpage.html.ejs | 2 +- src/layouts/core.html.ejs | 6 ++--- 7 files changed, 42 insertions(+), 21 deletions(-) diff --git a/docpad.js b/docpad.js index e41d3e0..c404ec5 100644 --- a/docpad.js +++ b/docpad.js @@ -7,12 +7,18 @@ var docpadConfig = { return this.getCollection("html").findAllLive({relativeOutDirPath: "."}, [{order: 1}]); }, posts: function(){ - return this.getCollection("html").findAll({relativeOutDirPath: "blog"}); + var posts = this.getCollection("html").findAllLive({relativeOutDirPath: "blog"}); + posts.on("add", function(post){ + post.setMetaDefaults({ + layout: "blogpost" + }); + }); + return posts; }, projects: function(){ var projects = this.getCollection("html").findAllLive({relativeOutDirPath: "projects"}); - projects.on("add", function(model){ - model.setMetaDefaults({ + projects.on("add", function(project){ + project.setMetaDefaults({ layout: "contentpage" }); }); diff --git a/src/documents/blog.html.ejs b/src/documents/blog.html.ejs index 6d58bc8..72183d5 100644 --- a/src/documents/blog.html.ejs +++ b/src/documents/blog.html.ejs @@ -8,10 +8,12 @@ referencesOthers: true <% var posts = getCollection("posts").toJSON() %> <% posts.forEach(function(post){ %>
-

<%= post.title %>

-
<%- post.formattedDate %>
-
- <%- post.contentRenderedWithoutLayouts.split("-split-")[0] %> -
+

<%= post.title %>

+

<%- post.subtitle %>

+

<%- post.formattedDate %>

+
+ <%- post.contentRenderedWithoutLayouts.split("-split-")[0] %> +
+ Read More...
<% }) %> diff --git a/src/documents/blog/2016-04-11-tvheadend-vm.html.md b/src/documents/blog/2016-04-11-tvheadend-vm.html.md index f52fc0b..641d087 100644 --- a/src/documents/blog/2016-04-11-tvheadend-vm.html.md +++ b/src/documents/blog/2016-04-11-tvheadend-vm.html.md @@ -1,5 +1,4 @@ --- -layout: "blogpost" title: "Running TVheadend in a VM" date: 2016-04-11 subtitle: "Or how I went from trying to watch HD TV to changing hypervisor..." diff --git a/src/documents/styles.css.scss b/src/documents/styles.css.scss index bea182f..291ec25 100644 --- a/src/documents/styles.css.scss +++ b/src/documents/styles.css.scss @@ -87,12 +87,9 @@ body{ margin-right: auto; margin-top: 10px; } - h1, h2, h3.date{ + h1, h2, h3{ text-align: center; } - h3.date{ - margin-top: 0px; - } h1{ margin-bottom: 5px; } @@ -439,14 +436,31 @@ body{ margin-right: auto; padding-top: 10px; padding-bottom: 10px; - h2, .date{ + + h2.title a{ + color: inherit; + } + h2.title, h3.subtitle, h4.date{ text-align: center; margin: 0; } + h3.subtitle, h4.date{ + font-weight: normal; + } } } -.blogpost{ +#content[data-slug^="blog-"]{ + h1#title{ + margin-bottom: 3px; + } + h2#subtitle, h3#date{ + margin: 0; + font-weight: normal; + } +} + +#content[data-slug^="blog"] .blogpost{ width: 100%; max-width: 800px; margin-left: auto; diff --git a/src/layouts/blogpost.html.ejs b/src/layouts/blogpost.html.ejs index 68bfbb0..e09a516 100644 --- a/src/layouts/blogpost.html.ejs +++ b/src/layouts/blogpost.html.ejs @@ -2,10 +2,10 @@ layout: contentpage --- -

<%- document.formattedDate %>

<% if(document.subtitle){ %> -

<%- document.subtitle %>

+

<%- document.subtitle %>

<% } %> +

<%- document.formattedDate %>

<%- content %>
diff --git a/src/layouts/contentpage.html.ejs b/src/layouts/contentpage.html.ejs index 2c8eb68..4012816 100644 --- a/src/layouts/contentpage.html.ejs +++ b/src/layouts/contentpage.html.ejs @@ -4,7 +4,7 @@ layout: core.html
-

<%- document.title %>

+

<%- document.title %>

<%- content %>
diff --git a/src/layouts/core.html.ejs b/src/layouts/core.html.ejs index e92c9b6..df162a7 100644 --- a/src/layouts/core.html.ejs +++ b/src/layouts/core.html.ejs @@ -18,18 +18,18 @@ <% var pages = getCollection("pages").toJSON() %> <% pages.forEach(function(page){ %> <% if(!page.hidden){ %> - active<% } %>" href="<%= page.url %>" data-rooturl="<%= page.url.split("/")[1] %>"> + active<% } %>" href="<%= page.url %>" data-rooturl="<%= page.url.split("/")[1] %>"> <% } %> <% }) %> -
+
" data-slug="<%- document.slug %>" /> <%- content.replace("-split-", "") %>