Initial commit

This commit is contained in:
cheddar 2025-04-16 22:47:29 -04:00
commit f3955f6322
No known key found for this signature in database
22 changed files with 2422 additions and 0 deletions

9
.editorconfig Normal file
View file

@ -0,0 +1,9 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
node_modules/
dist/

21
_config/filters.js Normal file
View file

@ -0,0 +1,21 @@
import { format } from 'date-fns';
export default function(eleventyConfig) {
eleventyConfig.addFilter("readableDate", (dateObj) => {
return format(dateOnly(dateObj), 'MMMM do, yyyy');
});
eleventyConfig.addFilter("htmlDateString", (dateObj) => {
return format(dateOnly(dateObj), 'yyyy-MM-dd');
});
eleventyConfig.addFilter("seriesPosts", (posts, seriesName) => {
return posts.
filter(post => post.data.series?.name == seriesName).
sort((a, b) => a.data.series.number - b.data.series.number);
});
function dateOnly(dateObj) {
return new Date(dateObj.getUTCFullYear(), dateObj.getUTCMonth(), dateObj.getUTCDate());
}
}

8
_data/metadata.js Normal file
View file

@ -0,0 +1,8 @@
export default {
title: 'CrispByte',
url: 'https://crispbyte.dev/',
author: {
name: 'CheddarCrisp',
url: 'https://crispbyte.dev/'
}
}

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>{% if title %}{{ title }} - {% endif %}{{ metadata.title }}</title>
</head>
<body>
{{ content | safe }}
<footer>{% include "site_nav.njk" %}</footer>
</body>
</html>

View file

@ -0,0 +1,30 @@
---
layout: layouts/base.njk
---
<article>
<h1>{{ title }}</h1>
<address>by <a href="{{ author.url or metadata.author.url }}">
{{ author.name or metadata.author.name }}
</a></address>
<time datetime="{{ page.date | htmlDateString }}">published {{ page.date | readableDate }}</time>
{% if series %}
<aside>This article is part of a series: <a href="#seriesNav">{{ series.name }}</a></aside>
{% endif %}
{{ content | safe }}
</article>
{% if collections.posts %}
{% set previousPost = collections.posts | getPreviousCollectionItem %}
{% set nextPost = collections.posts | getNextCollectionItem %}
{% if nextPost or previousPost %}
<nav name="Article Navigation">
<ol>
{% if previousPost %}<li><a href="{{ previousPost.url}}">{{ previousPost.data.title }}</a></li>{% endif %}
{% if nextPost %}<li><a href="{{ nextPost.url}}">{{ nextPost.data.title }}</a></li>{% endif %}
</ol>
</nav>
{% endif %}
{% endif %}
{% if series %}
{% set seriesName = series.name %}
<nav name="Series Name Directory" id="seriesNav">{% include "series_list.njk" %}</nav>
{% endif %}

7
_includes/post_link.njk Normal file
View file

@ -0,0 +1,7 @@
{% if page.url != post.url %}
<a href="{{ post.url }}">{{ post.data.title }}</a>
{% else %}
{{ post.data.title }}
{% endif %} -
<time datetime="{{ post.date | htmlDateString }}">{{ post.date | htmlDateString }}</time>
{% if post.data.description %}<p>{{ post.data.description }}</p>{% endif %}

6
_includes/post_list.njk Normal file
View file

@ -0,0 +1,6 @@
<ol>
{%- for post in collections.posts %}
<li>{% include "post_link.njk" %}</li>
{%- endfor %}
</ol>

View file

@ -0,0 +1,6 @@
<h2>{{ seriesName }}</h2>
<ol>
{%- for post in collections.posts | seriesPosts(seriesName) %}
<li>{% include "post_link.njk" %}</li>
{%- endfor %}
</ol>

7
_includes/site_nav.njk Normal file
View file

@ -0,0 +1,7 @@
<nav name="Site Navigation">
<ul>
{% for sitePage in collections.site_nav %}
<li><a href="{{ sitePage.url }}">{{ sitePage.data.title }}</a></li>
{% endfor %}
</ul>
</nav>

9
content/about.md Normal file
View file

@ -0,0 +1,9 @@
---
title: About Me
tags: site
nav_order: 3
---
# About Me
I am a human being. Most of the time.

10
content/blog/article1.md Normal file
View file

@ -0,0 +1,10 @@
---
title: The First Article
description: The first sample article thingy
date: 2025-04-16
series:
name: The Articles
number: 1
---
This is it. Come on, let's hear you SCREAM!

10
content/blog/article2.md Normal file
View file

@ -0,0 +1,10 @@
---
title: The Second Article
description: The second sample article thingy
date: 2025-04-16
series:
name: The Articles
number: 1
---
And here we have the second article

9
content/blog/article3.md Normal file
View file

@ -0,0 +1,9 @@
---
title: The Third Article
date: 2025-04-16
series:
name: The something elses
number: 3
---
This is something else entirely.

View file

@ -0,0 +1,6 @@
export default {
tags: [
"posts"
],
layout: 'layouts/post.njk'
}

View file

@ -0,0 +1,3 @@
export default {
layout: 'layouts/base.njk'
};

9
content/index.njk Normal file
View file

@ -0,0 +1,9 @@
---
title: Home
tags: site
nav_order: 1
---
<h1>This is the home page!</h1>
{% include "post_list.njk" %}

13
content/series.njk Normal file
View file

@ -0,0 +1,13 @@
---
title: Series
tags: site
nav_order: 2
---
<h1>Blog Series</h1>
<ol>
{%- for seriesName in collections.series %}
<li>{% include "series_list.njk" %}</li>
{%- endfor %}
</ol>

31
eleventy.config.js Normal file
View file

@ -0,0 +1,31 @@
import pluginFilters from "./_config/filters.js";
export default async function(eleventyConfig) {
eleventyConfig.addPlugin(pluginFilters);
eleventyConfig.addCollection("series", collectionsApi => {
const seriesNames = collectionsApi.
getFilteredByTag("posts").
filter(post => post.data.series != null).
map(post => post.data.series.name).
sort();
return [...new Set(seriesNames)];
});
eleventyConfig.addCollection("site_nav", collectionsApi => {
return collectionsApi.
getFilteredByTag("site").
filter(page => page.data.nav_order).
sort((a, b) => a.data.nav_order - b.data.nav_order);
});
};
export const config = {
dir: {
input: 'content',
includes: '../_includes',
data: '../_data',
output: 'dist'
}
};

2193
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

16
package.json Normal file
View file

@ -0,0 +1,16 @@
{
"name": "site-theme",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"@11ty/eleventy": "^3.0.0",
"date-fns": "^4.1.0"
}
}

7
shell.nix Normal file
View file

@ -0,0 +1,7 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
# nativeBuildInputs is usually what you want -- tools you need to run
nativeBuildInputs = with pkgs.buildPackages; [
nodejs_22
];
}