Skip to content

Commit 4b3c08c

Browse files
authored
Max updates from main home - Setup 11ty (https://www.11ty.dev) (brisbanesocialchess#403)
* change hostname * Init site generator * update gitignore * delete generated site * update git ignore * remove comments from config js * create 404 page * update deploy pr * improve performance * run prettier, run pre-commit, eslint * update * change in pre-commit config * exclude my md files in hook doctoc * change exclude in pre-commit * Normalize all line endings to LF * add eleventy-build-check to pre-commit
1 parent ba286c7 commit 4b3c08c

28 files changed

+3597
-1653
lines changed

.eleventy.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const { DateTime } = require('luxon');
2+
const slugify = require('slugify');
3+
4+
const getUniqueTaxonomy = (collectionApi, taxonomy) => {
5+
const allItems = collectionApi.getFilteredByGlob('posts/*.md').flatMap((item) => item.data[taxonomy] || []);
6+
return [...new Set(allItems)];
7+
};
8+
9+
module.exports = function (eleventyConfig) {
10+
eleventyConfig.addFilter('date', (dateObj, format = 'yyyy-MM-dd') => {
11+
return DateTime.fromJSDate(dateObj).toFormat(format);
12+
});
13+
14+
eleventyConfig.addFilter('slug', (str) => {
15+
return slugify(str, { lower: true, remove: /[*+~.()'"!:@]/g });
16+
});
17+
18+
eleventyConfig.addPassthroughCopy('assets');
19+
20+
eleventyConfig.addCollection('posts', function (collectionApi) {
21+
return collectionApi.getFilteredByGlob('posts/*.md').sort((a, b) => b.date - a.date);
22+
});
23+
24+
eleventyConfig.addCollection('categories', (collectionApi) => {
25+
return getUniqueTaxonomy(collectionApi, 'categories');
26+
});
27+
28+
eleventyConfig.addCollection('tags', (collectionApi) => {
29+
return getUniqueTaxonomy(collectionApi, 'tags');
30+
});
31+
32+
return {
33+
dir: {
34+
data: '_data',
35+
includes: '_includes',
36+
input: '.',
37+
output: '_site',
38+
},
39+
markdownTemplateEngine: 'njk',
40+
};
41+
};

.gitattributes

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Normalize line endings for text files
2-
* text=auto
2+
* text=auto eol=lf
33

44
# Content and code files
5-
*.md text
6-
*.html text
7-
*.css text
8-
*.js text
9-
*.toml text
10-
*.yaml text
11-
*.yml text
5+
*.md text eol=lf
6+
*.html text eol=lf
7+
*.css text eol=lf
8+
*.js text eol=lf
9+
*.toml text eol=lf
10+
*.yaml text eol=lf
11+
*.yml text eol=lf
1212

1313
# Binary files (images, fonts, PDFs)
1414
*.png binary

.github/linters/eslint.config.mjs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
import js from "@eslint/js";
2-
import globals from "globals";
3-
import prettierConfig from "eslint-config-prettier";
4-
import sortKeysFix from "eslint-plugin-sort-keys-fix";
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import prettierConfig from 'eslint-config-prettier';
4+
import sortKeysFix from 'eslint-plugin-sort-keys-fix';
55

66
export default [
7-
js.configs.recommended,
7+
js.configs.recommended,
88

9-
{
10-
ignores: ["**/.wrangler/**"],
11-
},
9+
{
10+
ignores: ['**/.wrangler/**'],
11+
},
1212

13-
{
14-
files: ["**/*.js"],
15-
languageOptions: {
16-
sourceType: "module",
17-
globals: {
18-
...globals.browser,
19-
...globals.node,
20-
},
21-
},
22-
plugins: {
23-
"sort-keys-fix": sortKeysFix,
24-
},
25-
rules: {
26-
"sort-keys-fix/sort-keys-fix": "error",
27-
},
28-
},
13+
{
14+
files: ['**/*.js'],
15+
languageOptions: {
16+
sourceType: 'module',
17+
globals: {
18+
...globals.browser,
19+
...globals.node,
20+
},
21+
},
22+
plugins: {
23+
'sort-keys-fix': sortKeysFix,
24+
},
25+
rules: {
26+
'sort-keys-fix/sort-keys-fix': 'error',
27+
},
28+
},
2929

30-
{
31-
files: ["docs/**/*.js"],
32-
languageOptions: {
33-
sourceType: "script",
34-
globals: globals.browser,
35-
},
36-
},
30+
{
31+
files: ['docs/**/*.js'],
32+
languageOptions: {
33+
sourceType: 'script',
34+
globals: globals.browser,
35+
},
36+
},
3737

38-
prettierConfig,
38+
prettierConfig,
3939
];
Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Build Pelican site on PR
1+
name: Build and Deploy Eleventy site
22

33
permissions:
44
contents: read
55

66
on:
7-
pull_request:
7+
push:
88
branches:
99
- main
1010

@@ -16,41 +16,19 @@ jobs:
1616
- name: Checkout repo
1717
uses: actions/checkout@v4
1818

19-
- name: Set up Python
20-
uses: actions/setup-python@v5
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
2121
with:
22-
python-version: '3.x'
23-
24-
- name: Check if pelicanconf.py exists
25-
id: check_pelicanconf
26-
run: |
27-
if [ -f pelicanconf.py ]; then
28-
echo "file_exists=true" >> "$GITHUB_OUTPUT"
29-
else
30-
echo "file_exists=false" >> "$GITHUB_OUTPUT"
31-
fi
22+
node-version: 22
3223

3324
- name: Install dependencies
34-
if: steps.check_pelicanconf.outputs.file_exists == 'true'
35-
run: |
36-
python -m pip install --upgrade pip
37-
pip install pelican markdown
38-
39-
- name: Build Pelican site
40-
if: steps.check_pelicanconf.outputs.file_exists == 'true'
41-
run: pelican content -o output -s pelicanconf.py
42-
43-
- name: Upload artifact (optional)
44-
if: steps.check_pelicanconf.outputs.file_exists == 'true'
45-
uses: actions/upload-artifact@v4
46-
with:
47-
name: pelican-site
48-
path: output/
25+
run: npm install
26+
27+
- name: Build Eleventy site
28+
run: npm run build
4929

5030
- name: Deploy to GitHub Pages
51-
if: github.event_name == 'pull_request' && steps.check_pelicanconf.outputs.file_exists == 'true'
5231
uses: peaceiris/actions-gh-pages@v4
5332
with:
5433
github_token: ${{ secrets.GITHUB_TOKEN }}
55-
publish_dir: ./output
56-
publish_branch: gh-pages-pr-${{ github.event.number }}
34+
publish_dir: ./_site

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Site builder
2+
_site
3+
14
# Editor directories
25
.vscode/
36
.idea/

.pre-commit-config.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,28 @@ repos:
4040
args: ['644']
4141
files: \.md$
4242
stages: [manual]
43+
- repo: local
44+
hooks:
45+
- id: eleventy-build-check
46+
name: Eleventy build and output check
47+
description: Run `npm run build`
48+
language: system
49+
entry: npm run build
50+
pass_filenames: false
4351
- repo: https://github.com/thlorenz/doctoc.git
4452
rev: v2.2.0
4553
hooks:
4654
- id: doctoc
4755
name: Add TOC for Markdown and RST files
4856
description: Adds a Markdown table of contents
4957
files: \.md$
50-
exclude: \.github/CODE_OF_CONDUCT\.md
58+
exclude: |
59+
(^posts/.*\.md$)|
60+
(^tags/.*\.md$)|
61+
(^categories/.*\.md$)|
62+
(^index\.md$)|
63+
(^404\.md$)|
64+
(^\.github/CODE_OF_CONDUCT\.md$)
5165
- repo: https://github.com/pycqa/isort
5266
rev: 6.0.1
5367
hooks:

404.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
permalink: /404.html
3+
layout: layouts/base.njk
4+
title: 404 - Page Not Found
5+
---
6+
7+
<h1>404 - Page Not Found</h1>
8+
<p>Sorry, the page you are looking for does not exist.</p>
9+
<a href="/">Go back home</a>

_includes/layouts/base.njk

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>{{ title }}</title>
6+
</head>
7+
<body>
8+
<header>
9+
<h1>{{ title }}</h1>
10+
<nav><a href="/">Home</a></nav>
11+
</header>
12+
<main>
13+
{{ content | safe }}
14+
</main>
15+
</body>
16+
</html>

categories/category.njk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
pagination:
3+
data: collections.categories
4+
size: 1
5+
alias: category
6+
permalink: "/categories/{{ category | slug }}/index.html"
7+
---
8+
9+
<h1>Posts in category: {{ category }}</h1>
10+
11+
<ul>
12+
{% for post in collections[category] %}
13+
<li><a href="{{ post.url }}">{{ post.data.title }}</a></li>
14+
{% endfor %}
15+
</ul>

docs/404.html

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en" dir="ltr">
3-
<head>
4-
<meta charset="UTF-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>404 Not Found – Brisbane Social Chess</title>
7-
<meta name="description" content="Page not found - Brisbane Social Chess" />
8-
<link rel="stylesheet" href="/style.css" />
9-
<link rel="icon" type="image/png" href="/assets/favicon.png" />
10-
<link rel="apple-touch-icon" href="/assets/apple-touch-icon.png" />
11-
</head>
12-
<body>
13-
<div class="background-overlay">
14-
<main class="content-wrapper">
15-
<div class="logo">
16-
<a href="/">
17-
<img src="/assets/logo.jpg" alt="Brisbane Social Chess Logo" />
18-
</a>
19-
<h1>Oops! Page Not Found</h1>
20-
<p>Looks like the page you're looking for doesn't exist.</p>
21-
</div>
22-
<nav class="nav-links">
23-
<a href="/">Home</a>
24-
<a href="/about.html">About</a>
25-
<a href="/games.html">Games</a>
26-
<a href="/meetup.html">Meetups</a>
27-
<a href="/minutes.html">Minutes</a>
28-
<a href="/register.html">Register</a>
29-
<a href="/rules.html">Rules</a>
30-
<a href="/terms.html">Terms</a>
31-
<a href="/contact.html">Contact</a>
32-
</nav>
33-
<section class="section">
34-
<h2>Error 404 – Not Found</h2>
35-
<p> Don’t worry, you haven’t blundered too badly. Maybe the link is outdated or there's a typo in the URL. </p>
36-
<p> You can return to our homepage or explore other sections of our site. </p>
37-
<div class="button-group">
38-
<a href="/" class="button">Go Home</a>
39-
</div>
40-
<img src="assets/locations.jpg" alt="Chess Pieces Lost" />
41-
</section>
42-
</main>
43-
</div>
44-
<footer class="site-footer">
45-
<p> &copy; <span id="year"></span> Brisbane Social Chess. All rights reserved. </p>
46-
</footer>
47-
<script type="text/javascript" src="/script.js"></script>
48-
</body>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>404 Not Found – Brisbane Social Chess</title>
7+
<meta name="description" content="Page not found - Brisbane Social Chess" />
8+
<link rel="stylesheet" href="/style.css" />
9+
<link rel="icon" type="image/png" href="/assets/favicon.png" />
10+
<link rel="apple-touch-icon" href="/assets/apple-touch-icon.png" />
11+
</head>
12+
<body>
13+
<div class="background-overlay">
14+
<main class="content-wrapper">
15+
<div class="logo">
16+
<a href="/">
17+
<img src="/assets/logo.jpg" alt="Brisbane Social Chess Logo" />
18+
</a>
19+
<h1>Oops! Page Not Found</h1>
20+
<p>Looks like the page you're looking for doesn't exist.</p>
21+
</div>
22+
<nav class="nav-links">
23+
<a href="/">Home</a>
24+
<a href="/about.html">About</a>
25+
<a href="/games.html">Games</a>
26+
<a href="/meetup.html">Meetups</a>
27+
<a href="/minutes.html">Minutes</a>
28+
<a href="/register.html">Register</a>
29+
<a href="/rules.html">Rules</a>
30+
<a href="/terms.html">Terms</a>
31+
<a href="/contact.html">Contact</a>
32+
</nav>
33+
<section class="section">
34+
<h2>Error 404 – Not Found</h2>
35+
<p>Don’t worry, you haven’t blundered too badly. Maybe the link is outdated or there's a typo in the URL.</p>
36+
<p>You can return to our homepage or explore other sections of our site.</p>
37+
<div class="button-group">
38+
<a href="/" class="button">Go Home</a>
39+
</div>
40+
<img src="assets/locations.jpg" alt="Chess Pieces Lost" />
41+
</section>
42+
</main>
43+
</div>
44+
<footer class="site-footer">
45+
<p>&copy; <span id="year"></span> Brisbane Social Chess. All rights reserved.</p>
46+
</footer>
47+
<script type="text/javascript" src="/script.js"></script>
48+
</body>
4949
</html>

0 commit comments

Comments
 (0)