Skip to content

Commit 42e57af

Browse files
lizellChristian Lizell
andauthored
refactor: Migrate from Jekyll to Eleventy 3.0 (#52)
* Migrate from Jekyll to Eleventy 3.0 This commit migrates the entire website from Jekyll (Ruby) to Eleventy (Node.js). Eleventy was chosen because it has native support for Liquid templates, which minimizes changes to existing templates. ## New files ### Configuration - eleventy.config.js: Main configuration in ESM format with collections, filters, and passthrough copy rules - package.json: Node.js dependencies (Eleventy, syntax highlighting, Sass) - .nvmrc: Node.js version 24 (current LTS) - .nojekyll: Prevents GitHub Pages from running Jekyll ### Data - _data/site.json: Site variables (url) - _data/home/roles.yml: Moved from _includes/ ### Layouts and templates - _layouts/employee.html: New layout for employee pages with content wrapper - _includes/lib/prism.scss: Syntax highlighting theme (replaces Rouge) - assets/site.js.liquid: JavaScript concatenation via Liquid template ### Directory data (for layout inheritance) - jobba/jobba.json - om-oss/om-oss.json - konsultnatverk/konsultnatverk.json - ai-labbet/ai-labbet.json - roller/roller.json - _posts/_posts.json ### CI/CD - .github/workflows/deploy.yml: GitHub Actions for automatic deployment ### Documentation - CLAUDE.md: Instructions for AI assistants and lessons learned from migration - AGENTS.md: Symbolic link to CLAUDE.md - README.md: Updated with new instructions for nvm and npm ## Deleted files - Gemfile, Gemfile.lock: Ruby dependencies - _config.yml: Jekyll configuration - .ruby-version: Ruby version - _includes/lib/rouge-github.scss: Rouge syntax highlighting (replaced by Prism) - assets/site.js: Replaced by site.js.liquid ## Template changes ### Variable access Jekyll: {{ page.title }}, {{ site.posts }} Eleventy: {{ title }}, {{ collections.posts }} ### Collection loops Jekyll: {% for post in site.posts %}{{ post.title }} Eleventy: {% for post in collections.posts %}{{ post.data.title }} ### Updated includes - _includes/home/blog.html: collections.posts, post.data.* - _includes/home/roles.html: home.roles instead of site.data.home.roles - _includes/blog/*.html: collections.posts, post.data.*, swedishDate filter - _includes/employees/index.html: collections.employees, employee.data.* ## Content changes ### Employee pages (_employees/*.md) - Added layout: employee for correct content wrapper ### Blog posts - Fixed {{page.image_url}} to {{image_url}} in 7 posts - Fixed markdown rendering after HTML blocks in acb2013.md (added blank lines after <h3> and <img> tags) - Updated old /images/employees/ paths to /assets/img/employees/ ### Other pages - Fixed {{page.*}} to {{*}} in ai-labbet, jobba, konsultnatverk, om-oss, roller ## SCSS changes - assets/site.scss: Changed from @import to @use (modern Sass syntax) - Sass is now compiled separately via npm script, not by Eleventy ## Configuration details ### Collections - posts: Sorted by date (newest first) with next/previous links - employees: Sorted alphabetically by filename ### Filters - swedishDate: Formats dates in Swedish (e.g., "24 januari 2025") - removeHtmlExtension: Removes .html from URLs ### Passthrough copy - assets/ - All image formats (jpg, png, gif, svg, webp) in all directories - favicon.ico ### Ignores - README.md, CLAUDE.md, AGENTS.md (documentation) - assets/blog/**/*.html and .md (demo files with Mustache syntax) - **/*.scss (compiled separately) * Update to Node.js 24 and add SCSS watch for development - Bump Node.js version to 24 in workflow, package.json and .nvmrc - Add sass:watch script for live SCSS recompilation - Run Eleventy and Sass watch in parallel during development * Update to Node.js 24 and add SCSS watch for development Changes: - Update Node.js requirement to version 24 (current LTS) - Add scripts/dev.mjs for parallel Eleventy and SCSS watch in development - Add sass:watch npm script for SCSS file watching - Fix intro_image variable name (was intro-image, now uses underscore) - Add pagination support to blog archive and index templates - Update deploy workflow to use Node.js 24 * Chore: add package-lock and use npm ci --------- Co-authored-by: Christian Lizell <christian.lizell@svt.se>
1 parent 16f1974 commit 42e57af

101 files changed

Lines changed: 2968 additions & 819 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/deploy.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [master]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '24'
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Build site
34+
run: npm run build
35+
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: _site
40+
41+
deploy:
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
runs-on: ubuntu-latest
46+
needs: build
47+
steps:
48+
- name: Deploy to GitHub Pages
49+
id: deployment
50+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
.idea
2-
.DS_Store
1+
# Build output
32
_site/
4-
.jekyll-metadata
3+
4+
# Node.js
5+
node_modules/
6+
7+
# Eleventy cache
8+
.cache/
9+
10+
# OS/IDE
11+
.DS_Store
12+
.idea/

.nojekyll

Whitespace-only changes.

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CLAUDE.md

CLAUDE.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# CLAUDE.md
2+
3+
Instruktioner och lärdomar för AI-assistenter som arbetar med detta projekt.
4+
5+
## Viktigt: Verifiera alltid aktuell information
6+
7+
**Lita INTE på egen kunskap om versioner, API:er eller aktuell syntax.**
8+
9+
Använd alltid:
10+
- **WebSearch** för att verifiera aktuella versioner (Node.js, npm-paket, etc.)
11+
- **Context7** (`mcp__context7__resolve-library-id` + `mcp__context7__query-docs`) för biblioteksdokumentation
12+
13+
Exempel på saker som ändras snabbt:
14+
- Node.js LTS-versioner
15+
- Framework-versioner och syntax
16+
- API-ändringar i bibliotek
17+
- Best practices
18+
19+
## Projektöversikt
20+
21+
Detta är Athegas webbplats, byggd med **Eleventy 3.0** (migrerad från Jekyll i januari 2025).
22+
23+
### Viktiga kommandon
24+
25+
```bash
26+
npm install # Installera beroenden
27+
npm start # Starta dev-server på localhost:8080
28+
npm run build # Bygg sajten till _site/
29+
```
30+
31+
### Nyckelkonfiguration
32+
33+
- **eleventy.config.js** - Huvudkonfiguration (ESM-format)
34+
- **package.json** - Beroenden och npm-scripts
35+
- **_data/site.json** - Site-variabler (url, etc.)
36+
37+
## Lärdomar från Jekyll → Eleventy-migrering
38+
39+
### 1. Variabelåtkomst i templates
40+
41+
**Jekyll:**
42+
```liquid
43+
{{ page.title }}
44+
{{ page.image_url }}
45+
{{ site.posts }}
46+
```
47+
48+
**Eleventy:**
49+
```liquid
50+
{{ title }}
51+
{{ image_url }}
52+
{{ collections.posts }}
53+
```
54+
55+
Front matter-variabler nås direkt utan `page.`-prefix i Eleventy.
56+
57+
### 2. Collection-data i loopar
58+
59+
I Eleventy nås front matter via `.data` när man itererar över collections:
60+
61+
```liquid
62+
{% for post in collections.posts %}
63+
{{ post.data.title }} <!-- OBS: .data. prefix -->
64+
{{ post.url }} <!-- url är direkt på objektet -->
65+
{% endfor %}
66+
```
67+
68+
### 3. Markdown efter HTML-block
69+
70+
Markdown-processorn (i både Jekyll och Eleventy) kräver en tom rad efter HTML-element för att fortsätta tolka Markdown:
71+
72+
**Fungerar inte:**
73+
```markdown
74+
<h3 id="rubrik">Min rubrik</h3>
75+
Text med [länk](http://example.com) fungerar inte.
76+
```
77+
78+
**Fungerar:**
79+
```markdown
80+
<h3 id="rubrik">Min rubrik</h3>
81+
82+
Text med [länk](http://example.com) fungerar nu.
83+
```
84+
85+
### 4. SCSS-hantering
86+
87+
Eleventy processar inte SCSS automatiskt. Vi kör Sass separat via npm:
88+
89+
```json
90+
"scripts": {
91+
"sass": "sass assets/site.scss:_site/assets/site.css --style=compressed",
92+
"build": "npm run sass && npx @11ty/eleventy"
93+
}
94+
```
95+
96+
**Modern Sass-syntax:** Använd `@use` istället för `@import`:
97+
```scss
98+
@use "lib/prism" as *;
99+
@use "layout" as *;
100+
```
101+
102+
`@use`-statements måste komma först i filen, före all annan kod.
103+
104+
### 5. JavaScript-konkatenering
105+
106+
`assets/site.js.liquid` är en Liquid-template som konkatenerar JS-filer:
107+
108+
```liquid
109+
---
110+
permalink: /assets/site.js
111+
layout: false
112+
---
113+
{% include "lib/jquery.min.js" %}
114+
{% include "header.js" %}
115+
```
116+
117+
Filen måste ha `.liquid`-extension för att processas som template.
118+
119+
### 6. Passthrough copy för bilder
120+
121+
Bilder i innehållsmappar (inte bara `assets/`) måste explicit kopieras:
122+
123+
```javascript
124+
eleventyConfig.addPassthroughCopy("**/*.jpg");
125+
eleventyConfig.addPassthroughCopy("**/*.png");
126+
// etc.
127+
```
128+
129+
### 7. Collection-sortering
130+
131+
Collections sorteras inte automatiskt som i Jekyll. Explicit sortering krävs:
132+
133+
```javascript
134+
// Alfabetisk sortering efter filnamn
135+
eleventyConfig.addCollection("employees", function(collection) {
136+
return collection.getFilteredByGlob("_employees/*.md")
137+
.sort((a, b) => a.inputPath.localeCompare(b.inputPath));
138+
});
139+
```
140+
141+
### 8. Layout-arv och wrappers
142+
143+
Sidor som behöver `<section class="content">` wrapper måste använda rätt layout:
144+
145+
- **page** - För vanliga innehållssidor
146+
- **post** - För blogginlägg
147+
- **employee** - För medarbetarsidor (ny layout skapad vid migrering)
148+
- **default** - Bas-layout utan content wrapper
149+
150+
### 9. Directory data files
151+
152+
För att sätta layout på alla filer i en mapp, skapa en JSON-fil med mappens namn:
153+
154+
```
155+
jobba/
156+
jobba.json # {"layout": "page"}
157+
index.md
158+
```
159+
160+
### 10. Syntax highlighting
161+
162+
Använder `@11ty/eleventy-plugin-syntaxhighlight` med Prism. CSS-tema finns i `_includes/lib/prism.scss`.
163+
164+
## Vanliga fallgropar
165+
166+
1. **Glöm inte `.data.`** när du läser front matter i collection-loopar
167+
2. **Tom rad efter HTML** krävs för att Markdown ska processas
168+
3. **Sortering av collections** måste göras explicit
169+
4. **Bilder utanför assets/** kopieras inte automatiskt
170+
5. **SCSS** kompileras separat, inte av Eleventy
171+
6. **`@use` före allt annat** i SCSS-filer
172+
7. **Dokumentationsfiler med Liquid-exempel** (som denna fil) måste läggas till i `eleventyConfig.ignores`, annars försöker Eleventy köra kodexemplen
173+
174+
## Testning vid ändringar
175+
176+
Efter ändringar, verifiera:
177+
178+
1. `npm run build` går igenom utan fel
179+
2. Startsidan renderar korrekt
180+
3. Blogginlägg visar rätt datum och innehåll
181+
4. Medarbetarsidor har rätt struktur
182+
5. Bilder laddas
183+
6. Interna länkar fungerar

Gemfile

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

0 commit comments

Comments
 (0)