Skip to content

Commit 362d4f4

Browse files
committed
Little tweaks
1 parent 45f0669 commit 362d4f4

8 files changed

Lines changed: 100 additions & 25 deletions

File tree

.eleventy.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,28 @@ module.exports = function (eleventyConfig) {
5858
const dirName = parts[parts.length - 2] || parts[parts.length - 1];
5959
return dirName.replace(/^\d{4}-\d{2}-\d{2}-/, "");
6060
});
61+
62+
// Watch for changes in CSS files for hot reload during development
63+
eleventyConfig.addWatchTarget("./static/**/*.css");
64+
65+
// Set browser sync options for better dev experience
66+
eleventyConfig.setBrowserSyncConfig({
67+
files: ["_site/**/*"],
68+
open: false, // Don't automatically open browser
69+
notify: false, // Disable browser sync notifications
70+
});
71+
72+
// Return explicit configuration
73+
return {
74+
dir: {
75+
input: "src",
76+
output: "_site",
77+
includes: "_includes",
78+
data: "_data",
79+
},
80+
// Use Liquid for HTML and Markdown, Nunjucks for .njk files
81+
markdownTemplateEngine: "liquid",
82+
htmlTemplateEngine: "njk",
83+
templateFormats: ["html", "njk", "md", "liquid"],
84+
};
6185
};

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ I use [11ty](https://www.11ty.dev/). This allows the use of markdown files which
1010

1111
By default everything in `./src` will get compiled by `11ty`. For any files which must be deployed but not built, they can be added to `./static`. Everything in `./static` will be copied as-is to the build output directory `./_site`. See `./.eleventy.js` for configuration.
1212

13+
## Development
14+
15+
Available npm scripts:
16+
17+
- `npm run build` - Build the site to `_site` directory
18+
- `npm run serve` - Start development server with live reload
19+
- `npm run clean` - Remove the `_site` directory
20+
- `npm run debug` - Build with debug output for troubleshooting
21+
22+
The development server includes:
23+
24+
- **Live reload**: Changes to CSS files trigger automatic browser refresh
25+
- **Hot reload**: Changes to content trigger automatic rebuild
26+
- **BrowserSync disabled notifications**: Cleaner development experience
27+
1328
## Deployment
1429

1530
Having produced a build in `_site`, the entire directory is pushed up on a `gh-pages` branch to GitHub, and hosted exactly as-is.
@@ -36,6 +51,15 @@ socialImage: https://example.com/custom-image.png # Optional: custom social medi
3651

3752
The `socialImage` field is optional. If not provided, a default image will be used for social media sharing (Open Graph and Twitter cards).
3853

54+
### Computed Data
55+
56+
Blog posts automatically have access to computed data:
57+
58+
- `absoluteUrl` - The full URL of the post (e.g., `https://rupertmckay.com/blog/my-post/`)
59+
- `socialImage` - Defaults to a standard image if not specified in front matter
60+
61+
These values are automatically computed and don't need to be manually added to each post.
62+
3963
## SEO Features
4064

4165
The site includes comprehensive SEO optimizations:

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
},
55
"scripts": {
66
"clean": "shx rm -rf _site",
7-
"build": "npx @11ty/eleventy --input=./src",
8-
"serve": "npx @11ty/eleventy --input=./src --serve"
7+
"build": "npx @11ty/eleventy",
8+
"serve": "npx @11ty/eleventy --serve",
9+
"debug": "DEBUG=Eleventy* npx @11ty/eleventy"
910
},
1011
"devDependencies": {
1112
"@11ty/eleventy": "^3.1.2",

src/_data/metadata.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/_data/site.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
url: "https://rupertmckay.com",
3+
title: "Rupert Foggo McKay",
4+
description: "Rupert's website.",
5+
author: {
6+
name: "Rupert Foggo McKay",
7+
email: "rupert@rupertmckay.com",
8+
},
9+
buildTime: new Date(),
10+
};

src/_includes/layouts/base.njk

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>{{ title or metadata.title }}</title>
7-
<meta name="description" content="{{ description or metadata.description }}">
6+
<title>{{ title or site.title }}</title>
7+
<meta name="description" content="{{ description or site.description }}">
88
<link rel="canonical" href="https://rupertmckay.com{{ page.url }}">
99
<link rel="shortcut icon" type="image/x-icon" href="{{ '/static/favicon.ico' | url }}">
1010
<link rel="stylesheet" href="{{ '/static/styles.css' | url }}">
1111
<link rel="stylesheet" href="{{ '/static/prism.css' | url }}">
12-
<link rel="alternate" type="application/atom+xml" title="{{ metadata.title }}" href="/feed.xml">
12+
<link rel="alternate" type="application/atom+xml" title="{{ site.title }}" href="/feed.xml">
1313

1414
<!-- Open Graph / Facebook -->
1515
<meta property="og:type" content="{% if layout == 'layouts/post.njk' %}article{% else %}website{% endif %}" />
1616
<meta property="og:url" content="https://rupertmckay.com{{ page.url }}" />
17-
<meta property="og:site_name" content="{{ metadata.title }}" />
18-
<meta property="og:title" content="{{ title or metadata.title }}" />
19-
<meta property="og:description" content="{{ description or metadata.description }}" />
17+
<meta property="og:site_name" content="{{ site.title }}" />
18+
<meta property="og:title" content="{{ title or site.title }}" />
19+
<meta property="og:description" content="{{ description or site.description }}" />
2020
<meta property="og:image" content="{{ socialImage or 'https://raw.githubusercontent.com/fildon/train-ride/main/train-ride.png' }}" />
2121
<meta property="og:image:type" content="image/png" />
2222
<meta property="og:image:width" content="1280" />
2323
<meta property="og:image:height" content="640" />
2424
{% if layout == 'layouts/post.njk' %}
2525
<meta property="article:published_time" content="{{ date | htmlDateString }}" />
26-
<meta property="article:author" content="{{ metadata.title }}" />
26+
<meta property="article:author" content="{{ site.author.name }}" />
2727
{% endif %}
2828

2929
<!-- Twitter -->
3030
<meta name="twitter:card" content="summary_large_image" />
3131
<meta property="twitter:domain" content="rupertmckay.com" />
3232
<meta property="twitter:url" content="https://rupertmckay.com{{ page.url }}" />
33-
<meta name="twitter:title" content="{{ title or metadata.title }}" />
34-
<meta name="twitter:description" content="{{ description or metadata.description }}" />
33+
<meta name="twitter:title" content="{{ title or site.title }}" />
34+
<meta name="twitter:description" content="{{ description or site.description }}" />
3535
<meta name="twitter:image" content="{{ socialImage or 'https://raw.githubusercontent.com/fildon/train-ride/main/train-ride.png' }}" />
3636

3737
<!-- JSON-LD Structured Data -->
@@ -41,10 +41,10 @@
4141
"@context": "https://schema.org",
4242
"@type": "BlogPosting",
4343
"headline": "{{ title }}",
44-
"description": "{{ description or metadata.description }}",
44+
"description": "{{ description or site.description }}",
4545
"author": {
4646
"@type": "Person",
47-
"name": "{{ metadata.title }}",
47+
"name": "{{ site.author.name }}",
4848
"url": "https://rupertmckay.com"
4949
},
5050
"datePublished": "{{ date | htmlDateString }}",
@@ -53,7 +53,7 @@
5353
"image": "{{ socialImage or 'https://raw.githubusercontent.com/fildon/train-ride/main/train-ride.png' }}",
5454
"publisher": {
5555
"@type": "Person",
56-
"name": "{{ metadata.title }}",
56+
"name": "{{ site.author.name }}",
5757
"url": "https://rupertmckay.com"
5858
},
5959
"mainEntityOfPage": {
@@ -67,12 +67,12 @@
6767
{
6868
"@context": "https://schema.org",
6969
"@type": "WebSite",
70-
"name": "{{ metadata.title }}",
71-
"description": "{{ metadata.description }}",
70+
"name": "{{ site.title }}",
71+
"description": "{{ site.description }}",
7272
"url": "https://rupertmckay.com",
7373
"author": {
7474
"@type": "Person",
75-
"name": "{{ metadata.title }}",
75+
"name": "{{ site.author.name }}",
7676
"url": "https://rupertmckay.com"
7777
}
7878
}

src/blog/blog.11tydata.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
// Automatically compute absolute URL for each blog post
3+
absoluteUrl: (data) => {
4+
if (data.page && data.page.url) {
5+
return `https://rupertmckay.com${data.page.url}`;
6+
}
7+
return "https://rupertmckay.com";
8+
},
9+
10+
// Compute permalink with date prefix stripped (already handled by blog.json)
11+
// but this makes it available as computed data
12+
13+
// Set default social image if not specified
14+
socialImage: (data) => {
15+
return (
16+
data.socialImage ||
17+
"https://raw.githubusercontent.com/fildon/train-ride/main/train-ride.png"
18+
);
19+
},
20+
};

src/feed.njk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ eleventyExcludeFromCollections: true
44
---
55
<?xml version="1.0" encoding="utf-8"?>
66
<feed xmlns="http://www.w3.org/2005/Atom">
7-
<title>{{ metadata.title }}</title>
8-
<subtitle>{{ metadata.description }}</subtitle>
7+
<title>{{ site.title }}</title>
8+
<subtitle>{{ site.description }}</subtitle>
99
<link href="https://rupertmckay.com/feed.xml" rel="self"/>
1010
<link href="https://rupertmckay.com/"/>
1111
<updated>{{ collections.blog | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
1212
<id>https://rupertmckay.com/</id>
1313
<author>
14-
<name>{{ metadata.title }}</name>
15-
<email>rupert@rupertmckay.com</email>
14+
<name>{{ site.author.name }}</name>
15+
<email>{{ site.author.email }}</email>
1616
</author>
1717
{%- for post in collections.blog | reverse %}
1818
{%- if loop.index <= 10 %}

0 commit comments

Comments
 (0)