Skip to content

Commit f91236f

Browse files
committed
v2.0.1
1 parent 20ac0ef commit f91236f

File tree

11 files changed

+147
-43
lines changed

11 files changed

+147
-43
lines changed

.eleventy.js

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1-
module.exports = function(eleventyConfig) {
1+
const { DateTime } = require("luxon");
2+
3+
module.exports = function (eleventyConfig) {
24
eleventyConfig.addPassthroughCopy("src/styles.css");
35
eleventyConfig.addPassthroughCopy("src/main.js");
4-
5-
eleventyConfig.addCollection("pages", function(collectionApi) {
6-
return collectionApi.getFilteredByGlob("src/sections/*.md").sort((a, b) => a.data.order - b.data.order);
6+
7+
eleventyConfig.addCollection("pages", function (collectionApi) {
8+
return collectionApi.getFilteredByGlob("src/sections/*.md").sort((a, b) => a.data.order - b.data.order);
79
});
8-
10+
11+
eleventyConfig.addCollection("blog", function (collectionApi) {
12+
return collectionApi.getFilteredByGlob("src/blog/*.md").sort((a, b) => {
13+
return b.date - a.date;
14+
});
15+
});
16+
17+
eleventyConfig.addFilter("date", (dateObj, format = "yyyy-MM-dd") => {
18+
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat(format);
19+
});
20+
921
return {
10-
dir: {
11-
input: "src",
12-
includes: "_includes",
13-
output: "_site"
14-
},
15-
markdownTemplateEngine: "njk",
16-
htmlTemplateEngine: "njk",
17-
dataTemplateEngine: "njk",
18-
templateFormats: ["md", "njk"]
22+
dir: {
23+
input: "src",
24+
includes: "_includes",
25+
output: "_site"
26+
},
27+
markdownTemplateEngine: "njk",
28+
htmlTemplateEngine: "njk",
29+
dataTemplateEngine: "njk",
30+
templateFormats: ["md", "njk"]
1931
};
20-
};
21-
32+
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"license": "ISC",
1515
"dependencies": {
1616
"@11ty/eleventy": "^3.0.0",
17+
"luxon": "^3.5.0",
1718
"sass": "^1.80.4",
1819
"scrollreveal": "^4.0.9"
1920
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/_includes/post.njk

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
layout: "base.njk"
3+
---
4+
5+
<main>
6+
<article>
7+
<section>
8+
{{ content | safe }}
9+
</section>
10+
</article>
11+
<hr style="margin-top: 30px; margin-bottom: 15px;" />
12+
<script src="https://giscus.app/client.js"
13+
data-repo="CLCK0622/11ty-Serene"
14+
data-repo-id="R_kgDOMgVOMw"
15+
data-category="Announcements"
16+
data-category-id="DIC_kwDOMgVOM84ClgHH"
17+
data-mapping="url"
18+
data-strict="0"
19+
data-reactions-enabled="1"
20+
data-emit-metadata="0"
21+
data-input-position="bottom"
22+
data-theme="preferred_color_scheme"
23+
data-lang="en"
24+
crossorigin="anonymous"
25+
async>
26+
</script>
27+
</main>

src/blog/first-post copy 2.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: "My First Blog Post"
3+
date: 2024-01-01
4+
layout: "post.njk"
5+
description: "This is the first blog post on my site."
6+
---
7+
8+
# My First Blog Post
9+
10+
Welcome to my blog! This is my first post.

src/blog/first-post copy.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: "My First Blog Post"
3+
date: 2024-01-03
4+
layout: "post.njk"
5+
description: "This is the first blog post on my site."
6+
---
7+
8+
# My First Blog Post
9+
10+
Welcome to my blog! This is my first post.

src/blog/first-post.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: "My First Blog Post"
3+
date: 2024-01-05
4+
layout: "post.njk"
5+
description: "This is the first blog post on my site."
6+
---
7+
8+
# My First Blog Post
9+
10+
Welcome to my blog! This is my first post.

src/main.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ document.addEventListener('DOMContentLoaded', (event) => {
22
init_mode();
33
});
44

5+
function updateGiscusTheme() {
6+
const theme = localStorage.theme === 'dark' ? 'dark' : 'light';
7+
const iframe = document.querySelector('iframe.giscus-frame');
8+
if (iframe) {
9+
iframe.contentWindow.postMessage(
10+
{ giscus: { setConfig: { theme: theme } } },
11+
'https://giscus.app'
12+
);
13+
}
14+
}
15+
516
function init_mode() {
617
const darkmodeCheckbox = document.getElementById("darkmode");
718
const htmlElement = document.documentElement;
@@ -13,6 +24,7 @@ function init_mode() {
1324
darkmodeCheckbox.checked = false;
1425
htmlElement.classList.remove('dark');
1526
}
27+
updateGiscusTheme();
1628
}
1729

1830
function change_mode() {
@@ -26,14 +38,14 @@ function change_mode() {
2638
localStorage.theme = 'light';
2739
htmlElement.classList.remove('dark');
2840
}
41+
updateGiscusTheme();
2942
}
3043

3144
document.addEventListener("DOMContentLoaded", () => {
3245
ScrollReveal().reveal("body *", {
33-
reset: true,
34-
distance: "0px",
35-
duration: 400,
36-
easing: "ease-in-out"
46+
reset: true,
47+
distance: "0px",
48+
duration: 400,
49+
easing: "ease-in-out"
3750
});
38-
});
39-
51+
});

src/sections/Blog.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ order: 3
77

88
# 💡 Blogs
99

10-
W.I.P...
11-
12-
Will support markdown in the future...
10+
<ul class="blogList">
11+
{% for post in collections.blog %}
12+
<li class=blogListItem>
13+
<a href="{{ post.url }}">{{ post.data.title }}</a> - {{ post.date | date("yyyy-MM-dd") }}
14+
<p>{{ post.data.description }}</p>
15+
</li>
16+
{% endfor %}
17+
</ul>

src/sections/Links.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ order: 4
66
---
77

88
# 🔗 Links
9+
10+
- 1
11+
- 2
12+
- 3

0 commit comments

Comments
 (0)