From 5dfef6e0d4007219cb8da98389f450fba3d225c1 Mon Sep 17 00:00:00 2001 From: maia arson crimew Date: Tue, 31 May 2022 16:10:07 +0200 Subject: [PATCH] add blog --- .eleventy.js | 22 +++++++++++++++++++--- src/_data/nav.json | 4 ++++ src/_includes/components/pagination.njk | 17 +++++++++++++++++ src/_includes/layouts/default.njk | 4 ++-- src/_includes/layouts/post.njk | 16 ++++++++++++++++ src/index.njk | 2 +- src/posts.njk | 21 +++++++++++++++++++++ src/posts/example.md | 9 +++++++++ src/posts/posts.json | 4 ++++ src/samples.njk | 7 ++++--- src/static/style.css | 21 +++++++++++++++++++-- 11 files changed, 116 insertions(+), 11 deletions(-) create mode 100644 src/_includes/components/pagination.njk create mode 100644 src/_includes/layouts/post.njk create mode 100644 src/posts.njk create mode 100644 src/posts/example.md create mode 100644 src/posts/posts.json diff --git a/.eleventy.js b/.eleventy.js index 57af464..e7df33a 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -3,17 +3,33 @@ module.exports = function (eleventyConfig) { if (str instanceof Date) { return str; } - const date = DateTime.fromISO(str, { zone: "utc" }); - return date.toJSDate(); + return Date.parse(str); }; + const formatPart = (part, date) => + new Intl.DateTimeFormat("en", part).format(date); + eleventyConfig.addPassthroughCopy({ "src/static": "/" }); eleventyConfig.addFilter("date_to_datetime", (obj) => { const date = parseDate(obj); - return DateTime.fromJSDate(date).toUTC().toISO(); + return date.toISOString(); }); + eleventyConfig.addFilter("date_formatted", (obj) => { + const date = parseDate(obj); + + const month = formatPart({ month: "short" }, date); + const day = formatPart({ day: "numeric" }, date); + const year = formatPart({ year: "numeric" }, date); + + return `${month} ${day}, ${year}`; + }); + + eleventyConfig.addCollection('posts', collection => { + return collection.getFilteredByGlob('src/posts/*.md').reverse() + }) + return { templateFormats: ["njk", "md", "html"], dir: { diff --git a/src/_data/nav.json b/src/_data/nav.json index 5c1bf82..c64bd16 100644 --- a/src/_data/nav.json +++ b/src/_data/nav.json @@ -3,6 +3,10 @@ "name": "home", "link": "/" }, + { + "name": "blog", + "link": "/posts/" + }, { "name": "sample packs", "link": "/samples/" diff --git a/src/_includes/components/pagination.njk b/src/_includes/components/pagination.njk new file mode 100644 index 0000000..b168225 --- /dev/null +++ b/src/_includes/components/pagination.njk @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/src/_includes/layouts/default.njk b/src/_includes/layouts/default.njk index e665c36..deec910 100644 --- a/src/_includes/layouts/default.njk +++ b/src/_includes/layouts/default.njk @@ -21,12 +21,12 @@ -
+
- {% block content %}{% endblock %} + {% block main %}{% endblock %}
{% include "components/footer.njk" %} diff --git a/src/_includes/layouts/post.njk b/src/_includes/layouts/post.njk new file mode 100644 index 0000000..23a1506 --- /dev/null +++ b/src/_includes/layouts/post.njk @@ -0,0 +1,16 @@ +--- +subhead: blog +--- +{% extends 'layouts/default.njk' %} +{% block main %} +
+
+ +

{{ title }}

+
+ {{ content | safe }} +
+{% endblock %} \ No newline at end of file diff --git a/src/index.njk b/src/index.njk index c625b5c..63beef1 100644 --- a/src/index.njk +++ b/src/index.njk @@ -2,7 +2,7 @@ permalink: /index.html --- {% extends 'layouts/default.njk' %} -{% block content %} +{% block main %}

hello i am {{ site.name }} ({{ site.pronouns }}) and this website is not finished at all as a matter of fact i havent even rly started working on it yet. diff --git a/src/posts.njk b/src/posts.njk new file mode 100644 index 0000000..a381d35 --- /dev/null +++ b/src/posts.njk @@ -0,0 +1,21 @@ +--- +title: maia blog :3 +subhead: blog +pagination: + data: collections.posts + addAllPagesToCollections: true + size: 10 +permalink: /posts/{% if pagination.pageNumber > 0 %}page/{{ pagination.pageNumber }}/{% endif %}index.html +--- +{% extends 'layouts/default.njk' %} +{% block main %} +

+ + {% include "components/pagination.njk" %} +{% endblock %} diff --git a/src/posts/example.md b/src/posts/example.md new file mode 100644 index 0000000..9509549 --- /dev/null +++ b/src/posts/example.md @@ -0,0 +1,9 @@ +--- +title: "example blog post" +date: 2022-05-31 +description: "owo" +--- + +test + +## test \ No newline at end of file diff --git a/src/posts/posts.json b/src/posts/posts.json new file mode 100644 index 0000000..08b472c --- /dev/null +++ b/src/posts/posts.json @@ -0,0 +1,4 @@ +{ + "layout": "layouts/post", + "permalink": "posts/{{ page.fileSlug }}/index.html" +} \ No newline at end of file diff --git a/src/samples.njk b/src/samples.njk index f778312..bd61279 100644 --- a/src/samples.njk +++ b/src/samples.njk @@ -1,15 +1,16 @@ --- -permalink: /samples/index.html +title: maia sample packs :3 subhead: sample packs +permalink: /samples/index.html --- {% extends 'layouts/default.njk' %} -{% block content %} +{% block main %}

here are some sample packs i made!

diff --git a/src/static/style.css b/src/static/style.css index ba73e99..6b1970c 100644 --- a/src/static/style.css +++ b/src/static/style.css @@ -12,7 +12,7 @@ li.lavender-webring-curr-site > a { color: rgb(195, 0, 255); } -header { +#site_header { padding-bottom: 5px; border-bottom: 1px solid rgb(255, 0, 140); } @@ -22,8 +22,8 @@ footer { border-top: 1px solid rgb(255, 0, 140); } -header, footer, +#site_header, .lavender-webring-container { text-align: center; } @@ -36,6 +36,23 @@ footer, padding-bottom: 2em; } +.byline { + font-size: 0.75rem; +} + +time, .author { + font-weight: bold; +} + +.article_header { + padding-bottom: 4px; + border-bottom: 1px dotted rgb(219, 103, 167); +} + +.article_header > h1 { + margin: 0.1rem; +} + .lavender-webring-container { all: unset; display: flex;