Skip to content

Commit df1f820

Browse files
committed
Improve Pagination and Add *Some* CSS.
1 parent f9f0c4b commit df1f820

21 files changed

+498
-37
lines changed

LICENSE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# The Modified MIT License
2+
3+
Copyright 2024-present by Reboot/Fitz, and Contributors.
4+
5+
Tl;dr (this is non-legally binding, and is only here as an abridged explanation of the following **binding** legal disclaimer under "License"): All source code is open to free reproduction and modification; we actually encourage you to use RCGI as a base/inspiration to build your own websites! All non-original content has its creator/author/license listed under "Acknowledgements". Have fun! `:]`
6+
7+
## License
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software") with exception of dialogue (Text associated with actions (including but not limited to speaking, movement, physical interactions, etc) performed within the story (also known as the Software)), images, audio, and video; to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so. All dialogue, images, audio, and video which do not have a separate license and/or author listed at the bottom of this document under "Acknowledgements" are under an all rights reserved license and require the express permission of Reboot/Fitz to be redistributed/modified. Redistribution/usage of the Software is subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14+
15+
## Acknowledgements
16+
17+
it's quite empty here...

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
11
# Reboot/Fitz's Site
22

3+
![Last Commit](https://img.shields.io/github/last-commit/Reboot-Codes/new-rcgi) ![Repo Size](https://img.shields.io/github/languages/code-size/Reboot-Codes/new-rcgi?color=brightgreen) ![GitHub Actions Build Workflow Status](https://img.shields.io/github/actions/workflow/status/Reboot-Codes/new-rcgi/build.yml)
4+
35
This is a remake of RCGI because it's kinda... jank. So, instead, we're using 11ty this go around.
6+
7+
## Build
8+
9+
Install dependencies with yarn and use `yarn build`. Simple as that! Eleventy will take care of building the site.
10+
11+
## Make Content
12+
13+
### Posts
14+
15+
To make a new post, just create it in `src/posts`. Give it a `title` in the front-matter, and everything else should be handled for you.
16+
17+
Tags automatically have pages generated.
18+
19+
### Projects
20+
21+
To make a project, decide on a project ID (referenced here as `$PROJECT_ID`), then on related posts, tag them with `project:$PROJECT_ID`.
22+
23+
In `src/projects`, make a page where the front-matter looks like the following:
24+
25+
```yaml
26+
title: $PROJECT_TITLE
27+
projectId: $PROJECT_ID
28+
pagination:
29+
data: collections.project:$PROJECT_ID
30+
```
31+
32+
Where `$PROJECT_TITLE` is the pretty name for the project. The content of that page will be like a blurb displayed above the posts for that project.

eleventy.config.js

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
const sass = require("sass");
22
const { feedPlugin } = require("@11ty/eleventy-plugin-rss");
3+
const markdownIt = require("markdown-it");
4+
const markdownItAnchor = require("markdown-it-anchor");
5+
const timeToRead = require('eleventy-plugin-time-to-read');
36

47
module.exports = function (eleventyConfig) {
5-
eleventyConfig.addTemplateFormats("scss");
8+
const md = markdownIt({ "html": true }).use(markdownItAnchor, {
9+
"level": 2,
10+
permalink: markdownItAnchor.permalink.headerLink()
11+
});
12+
eleventyConfig.setLibrary("md", md);
613

14+
eleventyConfig.addTemplateFormats("scss");
715
// Creates the extension for use
816
eleventyConfig.addExtension("scss", {
917
outputFileExtension: "css", // optional, default: "html"
@@ -19,6 +27,10 @@ module.exports = function (eleventyConfig) {
1927
},
2028
});
2129

30+
eleventyConfig.addPlugin(timeToRead, {
31+
speed: '250 words a minute'
32+
});
33+
2234
eleventyConfig.addCollection(
2335
"allPosts",
2436
function (collectionApi) {
@@ -60,6 +72,48 @@ module.exports = function (eleventyConfig) {
6072
return str.slice(num);
6173
});
6274

75+
// Return all the tags used in a collection
76+
eleventyConfig.addFilter("getAllTags", collection => {
77+
let tagSet = new Set();
78+
for(let item of collection) {
79+
(item.data.tags || []).forEach(tag => tagSet.add(tag));
80+
}
81+
return Array.from(tagSet);
82+
});
83+
84+
eleventyConfig.addFilter("filterTagList", function filterTagList(tags) {
85+
return (tags || []).filter(tag => ["all", "post", "allPosts", "project", "allProjects"].indexOf(tag) === -1).filter((tag) => (!(tag.startsWith("project:"))));
86+
});
87+
88+
const parseDate = (str) => {
89+
if (str instanceof Date) {
90+
return str;
91+
}
92+
return Date.parse(str);
93+
};
94+
95+
const formatPart = (part, date) =>
96+
new Intl.DateTimeFormat("en", part).format(date);
97+
98+
eleventyConfig.addFilter("formatDate", async (obj) => {
99+
if (!obj) {
100+
return "";
101+
}
102+
const date = parseDate(obj);
103+
104+
const month = formatPart({ month: "short" }, date);
105+
const day = formatPart({ day: "numeric" }, date);
106+
const year = formatPart({ year: "numeric" }, date);
107+
const hours = date.getUTCHours();
108+
const minutes = date.getUTCMinutes();
109+
110+
if (hours != 0 && minutes != 0) {
111+
return `${month} ${day}, ${year} - ${hours}:${minutes} UTC`;
112+
}
113+
114+
return `${month} ${day}, ${year}`;
115+
});
116+
63117
return {
64118
dir: {
65119
input: "src",

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
22
"name": "rebootfitz-newsite",
33
"scripts": {
4-
"build": "eleventy"
4+
"build": "eleventy",
5+
"dev": "eleventy --serve"
56
},
67
"dependencies": {
78
"@11ty/eleventy": ">=3.0.0-alpha.15",
89
"@11ty/eleventy-plugin-rss": "^2.0.2",
10+
"eleventy-plugin-time-to-read": "^1.3.0",
11+
"markdown-it": "^14.1.0",
12+
"markdown-it-anchor": "^9.0.1",
913
"sass": "^1.77.8"
1014
}
1115
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
<nav>
1+
<nav id="navbar" class="nav-bar">
2+
<a id="section-title" class="nav-title" href="/">{% include "copywriting/sectionTitle.njk" %}</a>
23
{% for navLink in nav %}
3-
<a href="{{ navLink.href }}">{{ navLink.title }}</a>
4+
<a id="nav-item-{{ loop.index }}" class="nav-item" href="{{ navLink.href }}">{{ navLink.title }}</a>
45
{% endfor %}
56
</nav>
Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,52 @@
11
{% if ((pagination.hrefs | length) > 1) %}
2-
<ul>
3-
<li><a href="{{ pagination.hrefs[0] }}"{% if page.url == pagination.hrefs[0] %} aria-current="page"{% endif %}>First</a></li>
4-
<li>{% if pagination.href.previous %}<a href="{{ pagination.href.previous }}">Previous</a>{% else %}Previous{% endif %}</li>
5-
{%- for pageEntry in pagination.pages %}
6-
<li><a href="{{ pagination.hrefs[ loop.index0 ] }}"{% if page.url == pagination.hrefs[ loop.index0 ] %} aria-current="page"{% endif %}>Page {{ loop.index }}</a></li>
7-
{%- endfor %}
8-
<li>{% if pagination.href.next %}<a href="{{ pagination.href.next }}">Next</a>{% else %}Next{% endif %}</li>
9-
<li><a href="{{ pagination.hrefs[(pagination.hrefs | length) - 1] }}"{% if page.url == pagination.hrefs[-1] %} aria-current="page"{% endif %}>Last</a></li>
2+
<ul {% if paginationId %}id="{{ paginationId }}"{% endif %} class="pagination{% if paginationClasses %}{{ paginationClasses }}{% endif %}">
3+
<li {% if paginationId %}id="{{ paginationId }}-first"{% endif %} class="pagination-first pagination-control"{% if page.url == pagination.hrefs[0] %} aria-current="page">First{% else %}><a href="{{ pagination.hrefs[0] }}">First</a>{% endif %}</li>
4+
<li {% if paginationId %}id="{{ paginationId }}-previous"{% endif %} class="pagination-previous pagination-control"{% if pagination.href.previous %}><a href="{{ pagination.href.previous }}">Previous</a>{% else %} aria-current="page">Previous{% endif %}</li>
5+
6+
7+
{% if ((pagination.pages | length) > 5) %}
8+
{% if pagination.pageNumber == 0 %}
9+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 1 }}" {% endif %} class="pagination-item pagination-control" aria-current="page">Page {{ pagination.pageNumber + 1 }}</li>
10+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 2 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber + 1] }}">Page {{ pagination.pageNumber + 2 }}</a></li>
11+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 3 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber + 2] }}">Page {{ pagination.pageNumber + 3 }}</a></li>
12+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 4 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber + 3] }}">Page {{ pagination.pageNumber + 4 }}</a></li>
13+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 5 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber + 4] }}">Page {{ pagination.pageNumber + 5 }}</a></li>
14+
15+
{% elif pagination.pageNumber == 1 %}
16+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber - 1] }}">Page {{ pagination.pageNumber }}</a></li>
17+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 1 }}" {% endif %} class="pagination-item pagination-control" aria-current="page">Page {{ pagination.pageNumber + 1 }}</li>
18+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 2 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber + 1] }}">Page {{ pagination.pageNumber + 2 }}</a></li>
19+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 3 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber + 2] }}">Page {{ pagination.pageNumber + 3 }}</a></li>
20+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 4 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber + 3] }}">Page {{ pagination.pageNumber + 4 }}</a></li>
21+
22+
{% elif pagination.pageNumber == ((pagination.pages | length) - 2) %}
23+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber - 2 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber - 3] }}">Page {{ pagination.pageNumber - 2 }}</a></li>
24+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber - 1 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber - 2] }}">Page {{ pagination.pageNumber - 1 }}</a></li>
25+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber - 1] }}">Page {{ pagination.pageNumber }}</a></li>
26+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 1 }}" {% endif %} class="pagination-item pagination-control" aria-current="page">Page {{ pagination.pageNumber + 1 }}</li>
27+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 2 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber + 1] }}">Page {{ pagination.pageNumber + 2 }}</a></li>
28+
29+
{% elif pagination.pageNumber == ((pagination.pages | length) - 1) %}
30+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber - 3 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber - 4] }}">Page {{ pagination.pageNumber - 3 }}</a></li>
31+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber - 2 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber - 3] }}">Page {{ pagination.pageNumber - 2 }}</a></li>
32+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber - 1 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber - 2] }}">Page {{ pagination.pageNumber - 1 }}</a></li>
33+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber - 1] }}">Page {{ pagination.pageNumber }}</a></li>
34+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 1 }}" {% endif %} class="pagination-item pagination-control" aria-current="page">Page {{ pagination.pageNumber + 1 }}</li>
35+
36+
{% else %}
37+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber - 1 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber - 2] }}">Page {{ pagination.pageNumber - 1 }}</a></li>
38+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber - 1] }}">Page {{ pagination.pageNumber }}</a></li>
39+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 1 }}" {% endif %} class="pagination-item pagination-control" aria-current="page">Page {{ pagination.pageNumber + 1 }}</li>
40+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 2 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber + 1] }}">Page {{ pagination.pageNumber + 2 }}</a></li>
41+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ pagination.pageNumber + 3 }}" {% endif %} class="pagination-item pagination-control"><a href="{{ pagination.hrefs[pagination.pageNumber + 2] }}">Page {{ pagination.pageNumber + 3 }}</a></li>
42+
{% endif %}
43+
{% else %}
44+
{% for pageEntry in pagination.pages %}
45+
<li{% if paginationId %}id="{{ paginationId }}-item-{{ loop.index }}" {% endif %} class="pagination-item pagination-control" {% if page.url == pagination.hrefs[loop.index - 1] %} aria-current="page">Page {{ loop.index }}{% else %}><a href="{{ pagination.hrefs[ loop.index0 ] }}">Page {{ loop.index }}</a>{% endif %}</li>
46+
{% endfor %}
47+
{% endif %}
48+
49+
<li{% if paginationId %}id="{{ paginationId }}-next" {% endif %} class="pagination-next pagination-control"{% if pagination.href.next %}><a href="{{ pagination.href.next }}">Next</a>{% else %} aria-current="page">Next{% endif %}</li>
50+
<li{% if paginationId %}id="{{ paginationId }}-last" {% endif %} class="pagination-last pagination-control"{% if page.url == pagination.hrefs[(pagination.hrefs | length) - 1] %} aria-current="page">Last{% else %}><a href="{{ pagination.hrefs[(pagination.hrefs | length) - 1] }}">Last</a>{% endif %}</li>
1051
</ul>
1152
{% endif %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% if isBlog %}{{ generalData.blog.title }}{% elif isProject %}{{ generalData.workshop.title }}{% else %}{{ generalData.site.title }}{% endif %}

src/_includes/copywriting/title.njk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% include "copywriting/sectionTitle.njk" %}{% if title %} - {{ title }}{% endif %}

src/_includes/layouts/base.njk

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
---
22
isBlog: false
3+
useContainer: true
34
---
45

56
<!DOCTYPE html>
67
<html lang="en">
78
<head>
89
<meta charset="UTF-8">
910
<meta name="viewport" content="width=device-width, initial-scale=1.0">
10-
<title>
11-
{% if isBlog %}{{ generalData.blog.title }}{% elif isProject %}{{ generalData.workshop.title }}{% else %}{{ generalData.site.title }}{% endif %}{% if title %} - {{ title }}{% endif %}
12-
</title>
11+
<title>{% include "copywriting/title.njk" %}</title>
1312
<link rel="stylesheet" href="/styles/global.css" />
1413
</head>
1514
<body>
1615
{% include "components/navigation.njk" %}
17-
<main>
16+
<main id="page-content" {% if useContainer %}class="page-container"{% endif %}>
1817
{{ content | safe }}
1918
</main>
2019
{% include "components/footer.njk" %}

src/_includes/layouts/post.njk

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
---
22
layout: base.njk
33
isBlog: true
4+
useContainer: true
45
---
56

67
<h1>{{ title }}</h1>
78

9+
<p>on {{ page.date | formatDate }}, takes {{ content | timeToRead }} to read.</p>
10+
11+
<h2>Tags</h2>
812
{% if ((tags | length) > 1) %}
9-
<h2>Tags</h2>
10-
<ul>
11-
{% for tag in tags %}
12-
{% if tag != "post" %}
13-
{% if (tag | startsWith("project:")) %}
14-
<li><a href="/projects/{{ tag | strSlice(8) }}">Project: {% for project in collections.allProjects %}{% if (project.data.projectId == (tag | strSlice(8))) %}{{ project.data.title }}{% endif %}{% endfor %}</a></li>
15-
{% else %}
16-
<li><a>{{ tag }}</a></li>
17-
{% endif %}
13+
<ul>
14+
{% for tag in tags %}
15+
{% if tag != "post" %}
16+
{% if (tag | startsWith("project:")) %}
17+
<li><a href="/projects/{{ tag | strSlice(8) }}">Project: {% for project in collections.allProjects %}{% if (project.data.projectId == (tag | strSlice(8))) %}{{ project.data.title }}{% endif %}{% endfor %}</a></li>
18+
{% else %}
19+
<li><a href="/tags/{{ tag }}">{{ tag }}</a></li>
1820
{% endif %}
19-
{% endfor %}
20-
</ul>
21+
{% endif %}
22+
{% endfor %}
23+
</ul>
24+
{% else %}
25+
<p>No tags</p>
2126
{% endif %}
2227

28+
<div id="post-content" class="content">
2329
{{ content | safe }}
24-
30+
<div>

0 commit comments

Comments
 (0)