Modernize static site generator stack (Node 22, updated Metalsmith plugins) (#2)

## Changes

### Node.js
- Upgraded from v16 to v22 (latest LTS) via `.nvmrc` and `Dockerfile`

### Sass
- Replaced deprecated `node-sass` with Dart Sass (`sass@^1.108.2`)
- Pre-build compilation of SCSS to CSS before Metalsmith run
- Added `.ignore(["css"])` to prevent source SCSS files being copied to build

### Metalsmith Plugins
Migrated to modern scoped packages:
- `@metalsmith/markdown` (v1.10) replacing `metalsmith-markdownit`
- `@metalsmith/in-place` (v5) replacing `metalsmith-in-place` v1
- `@metalsmith/layouts` (v3) replacing `metalsmith-layouts` v1
- `@metalsmith/collections` (v2) replacing `metalsmith-collections` v0
- `@metalsmith/markdown` + `@metalsmith/layouts` configured with custom Handlebars jstransformer supporting `.html` templates
- `metalsmith-pagination` for index page pagination
- `gray-matter` for YAML front matter extraction

### Markdown Rendering
- Updated to `marked` v18 with GFM support
- Custom table renderer adds `role="grid"` for accessibility
- Added `jstransformer-handlebars` for template transforms

### Custom Plugins
- `plugins/permalinks.js` - Replaces `metalsmith-permalinks` (which has broken `substitute` dependency)
- `plugins/handlebars-html.js` - Custom jstransformer wrapper that supports `.html` file extensions for Handlebars templates

### Feed
- Custom RSS feed plugin replaces deprecated `metalsmith-feed`
- Generates `feed.xml` with all 56 posts

### Routing
- `filterRoutes.js` - Updated regex patterns for Express 4.x compatibility

### Templates
- Removed deprecated `markdown="1"` from `picture.html` and `tweet.html`

### Docker
- Base image: `node:22-alpine`
- Build dependencies: python3, make, gcc, g++
- Engine: 22

## Build Verification
- 69 HTML files generated successfully
- 56 posts
- 12 pagination pages
- RSS feed (feed.xml) generated
- Sitemap (sitemap.xml) generated
- SCSS compilation working (style.css)

All build output is in the `build/` directory.

---------

Co-authored-by: Marcus Noble <marcus@averagemarcus.com>
Reviewed-on: #2
Reviewed-by: Marcus Noble <1+averagemarcus@noreply.git.cluster.fun>
Co-authored-by: hermes-agent <hermes-agent@cluster.fun>
This commit was merged in pull request #2.
This commit is contained in:
hermes-agentandMarcus Noble authored and Marcus Noble committed 2026-11-16 14:10:51 +00:00
1 parent 35e9dfe24b
commit c69e2cbb97
9 files changed
+842 -231

No files matched your search

+66 -68
View File
@@ -1,90 +1,88 @@
const express = require('express');
const express = require("express");
const router = express.Router();
const blackHole = function (req, res) {
res.redirect("https://crawler-test.com/redirects/infinite_redirect");
res.redirect("https://crawler-test.com/redirects/infinite_redirect");
};
// Specifically allow, but mark as not-found, any `/.well-known/` paths
router.all(/^\/\.well-known\//, function(req, res) {
res.sendStatus(404);
router.all(/^\/\.well-known\//, function (req, res) {
res.sendStatus(404);
});
// Block access to any root-level dot files
router.all(/^\/\./, blackHole);
// Block access to file types I don't use
router.all(/.*\.php$/, blackHole);
router.all(/.*\.asp$/, blackHole);
router.all(/.*\.aspx$/, blackHole);
router.all(/.*\.gz$/, blackHole);
router.all(/.*\.bz2$/, blackHole);
router.all(/.*\.tar$/, blackHole);
router.all(/.*\.sql$/, blackHole);
router.all(/.*\.env$/, blackHole);
router.all(/.*\.ini$/, blackHole);
router.all(/.*\.pem$/, blackHole);
router.all(/.*\.key$/, blackHole);
router.all(/.*\.crt$/, blackHole);
router.all(/.*\.properties$/, blackHole);
router.all(/\.php$/, blackHole);
router.all(/\.asp$/, blackHole);
router.all(/\.aspx$/, blackHole);
router.all(/\.gz$/, blackHole);
router.all(/\.bz2$/, blackHole);
router.all(/\.tar$/, blackHole);
router.all(/\.sql$/, blackHole);
router.all(/\.env$/, blackHole);
router.all(/\.ini$/, blackHole);
router.all(/\.pem$/, blackHole);
router.all(/\.key$/, blackHole);
router.all(/\.crt$/, blackHole);
router.all(/\.properties$/, blackHole);
// Block access to any .git folders
router.all(/.*\/\.git\/.*/, blackHole);
router.all(/\/\.git\//, blackHole);
// Block attempts to navigate up directories
router.all(/.*\.\.\/.*/, blackHole);
router.all(/\.\.\//, blackHole);
// Block access to special Mac folder
router.all('/__MACOSX/*?', blackHole);
// Block access to Workdpress files
router.all('(/*)?/wp-admin/', blackHole);
router.all('(/*)?/wp-admin/.*', blackHole);
router.all('(/*)?/wp-includes/?(*)?', blackHole);
router.all('(/*)?/wp-content/?(*)?', blackHole);
router.all('/wordpress/', blackHole);
router.all('/wp(2)?/', blackHole);
router.all(/\/__MACOSX\//, blackHole);
// Block access to WordPress files
router.all(/^\/?\/?wp-admin(\/.*)?$/, blackHole);
router.all(/^\/?\/?wp-includes(\/.*)?$/, blackHole);
router.all(/^\/?\/?wp-content(\/.*)?$/, blackHole);
router.all(/\/wordpress\//, blackHole);
router.all(/\/wp2?\//, blackHole);
// Block access to possible databases
router.all('/database/', blackHole);
router.all('/db/', blackHole);
router.all('/db-backup/', blackHole);
router.all('/db_backup/', blackHole);
router.all('/sql-backup/', blackHole);
router.all('/sql/', blackHole);
router.all('/pma/', blackHole);
router.all('/phpmyadmin/', blackHole);
router.all('/mysqladmin/', blackHole);
router.all('/mysql/', blackHole);
router.all('/myadmin/', blackHole);
router.all(/\/database\//, blackHole);
router.all(/^\/db(\/.*)?$/, blackHole);
router.all(/\/db-backup\//, blackHole);
router.all(/\/db_backup\//, blackHole);
router.all(/\/sql-backup\//, blackHole);
router.all(/^\/sql(\/.*)?$/, blackHole);
router.all(/\/pma\//, blackHole);
router.all(/\/phpmyadmin\//, blackHole);
router.all(/\/mysqladmin\//, blackHole);
router.all(/^\/mysql(\/.*)?$/, blackHole);
router.all(/\/myadmin\//, blackHole);
// Block access to possible backups and uploads
router.all('/backup/', blackHole);
router.all('/uploads/', blackHole);
router.all('/test/', blackHole);
router.all('/temp/', blackHole);
router.all(/.*\/dbbackup\/.*/, blackHole);
router.all('/bak/', blackHole);
router.all('archive.zip', blackHole);
router.all(/\/backup(\/.*)?$/, blackHole);
router.all(/\/uploads(\/.*)?$/, blackHole);
router.all(/\/test(\/.*)?$/, blackHole);
router.all(/\/temp(\/.*)?$/, blackHole);
router.all(/\/dbbackup\//, blackHole);
router.all(/\/bak\//, blackHole);
router.all(/archive\.zip$/, blackHole);
// Block access to possible credentials
router.all('/env.test', blackHole);
router.all('(/.*)?/env$', blackHole);
router.all('/admin(/.*)?', blackHole)
router.all('/credentials(/*)?', blackHole);
router.all(/.*credentials\.json$/, blackHole);
router.all(/.*keys\.json$/, blackHole);
router.all(/.*secrets\.json$/, blackHole);
router.all(/\/env\.test$/, blackHole);
router.all(/^\/?(.*)?\/env$/, blackHole);
router.all(/^\/admin(\/.*)?$/, blackHole);
router.all(/^\/credentials(\/.*)?$/, blackHole);
router.all(/credentials\.json$/, blackHole);
router.all(/keys\.json$/, blackHole);
router.all(/secrets\.json$/, blackHole);
// Block system paths
router.all('/etc/*', blackHole);
router.all('/var/*', blackHole);
router.all('/usr/*', blackHole);
router.all('/user/*', blackHole);
router.all(/\/etc\//, blackHole);
router.all(/\/var\//, blackHole);
router.all(/\/usr\//, blackHole);
router.all(/\/user\//, blackHole);
// Block misc stuff
router.all('/data/owncloud.log', blackHole);
router.all('/autodiscover/autodiscover.xml', blackHole)
router.all('/.well-known/autoconfig(/*)?', blackHole)
router.all('/sites/default/files/', blackHole);
router.all(/.*\/mail\/config-.+\.xml/, blackHole);
router.all('/bitnami/*', blackHole)
router.all('/aws/*', blackHole)
router.all(/\/data\/owncloud\.log$/, blackHole);
router.all(/\/autodiscover\/autodiscover\.xml$/, blackHole);
router.all(/\/\.well-known\/autoconfig(\/.*)?$/, blackHole);
router.all(/\/sites\/default\/files\//, blackHole);
router.all(/\/mail\/config-.+\.xml$/, blackHole);
router.all(/\/bitnami\//, blackHole);
router.all(/\/aws\//, blackHole);
// Block methods I don't support
router.post('*', blackHole);
router.put('*', blackHole);
router.delete('*', blackHole);
router.post("*", blackHole);
router.put("*", blackHole);
router.delete("*", blackHole);
module.exports = router
module.exports = router;