diff --git a/web/documents/using-firefox-micro-summaries/screenshot-live_titles-1.png b/assets/dev/documents/using-firefox-micro-summaries/screenshot-live_titles-1.png similarity index 100% rename from web/documents/using-firefox-micro-summaries/screenshot-live_titles-1.png rename to assets/dev/documents/using-firefox-micro-summaries/screenshot-live_titles-1.png diff --git a/web/documents/using-firefox-micro-summaries/screenshot-live_titles-2.png b/assets/dev/documents/using-firefox-micro-summaries/screenshot-live_titles-2.png similarity index 100% rename from web/documents/using-firefox-micro-summaries/screenshot-live_titles-2.png rename to assets/dev/documents/using-firefox-micro-summaries/screenshot-live_titles-2.png diff --git a/web/documents/using-firefox-micro-summaries/screenshot-live_titles-3.png b/assets/dev/documents/using-firefox-micro-summaries/screenshot-live_titles-3.png similarity index 100% rename from web/documents/using-firefox-micro-summaries/screenshot-live_titles-3.png rename to assets/dev/documents/using-firefox-micro-summaries/screenshot-live_titles-3.png diff --git a/web/documents/using-firefox-micro-summaries/screenshot-xpath-1.png b/assets/dev/documents/using-firefox-micro-summaries/screenshot-xpath-1.png similarity index 100% rename from web/documents/using-firefox-micro-summaries/screenshot-xpath-1.png rename to assets/dev/documents/using-firefox-micro-summaries/screenshot-xpath-1.png diff --git a/web/documents/using-firefox-micro-summaries/screenshot-xpath-2.png b/assets/dev/documents/using-firefox-micro-summaries/screenshot-xpath-2.png similarity index 100% rename from web/documents/using-firefox-micro-summaries/screenshot-xpath-2.png rename to assets/dev/documents/using-firefox-micro-summaries/screenshot-xpath-2.png diff --git a/web/documents/wizpym/01_wizpym_sample_welcome_pane.png b/assets/dev/documents/wizpym/01_wizpym_sample_welcome_pane.png similarity index 100% rename from web/documents/wizpym/01_wizpym_sample_welcome_pane.png rename to assets/dev/documents/wizpym/01_wizpym_sample_welcome_pane.png diff --git a/web/documents/wizpym/02_wizpym_sample_input_pane.png b/assets/dev/documents/wizpym/02_wizpym_sample_input_pane.png similarity index 100% rename from web/documents/wizpym/02_wizpym_sample_input_pane.png rename to assets/dev/documents/wizpym/02_wizpym_sample_input_pane.png diff --git a/web/documents/wizpym/03_wizpym_sample_search_pane.png b/assets/dev/documents/wizpym/03_wizpym_sample_search_pane.png similarity index 100% rename from web/documents/wizpym/03_wizpym_sample_search_pane.png rename to assets/dev/documents/wizpym/03_wizpym_sample_search_pane.png diff --git a/package-lock.json b/package-lock.json index 1a9d740..17992a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "david.soulayrol.name", "version": "2022.06", "devDependencies": { + "@metalsmith/collections": "1.3.0", "@metalsmith/layouts": "2.4.0", "@metalsmith/markdown": "1.9.1", "@metalsmith/permalinks": "^2.4.0", @@ -28,7 +29,6 @@ "metalsmith": "^2.4.0", "metalsmith-assets": "^0.1.0", "metalsmith-groff": "^0.3.0", - "metalsmith-rename": "^1.0.0", "metalsmith-sitemap": "^1.2.2", "nodemon": "^2.0.12", "rimraf": "^3.0.2", @@ -570,6 +570,28 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "node_modules/@metalsmith/collections": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@metalsmith/collections/-/collections-1.3.0.tgz", + "integrity": "sha512-RnTyDeDvlOPQ6/yisUeCVfy4gjPzImW9lDTP9gbQa1I5EAZ6kXrvlSnMxiIqqQ9/VPePv68TOXJRqkancfF2bA==", + "dev": true, + "dependencies": { + "lodash.get": "^4.4.2", + "read-metadata": "^1.0.0" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "metalsmith": "^2.5.0" + } + }, + "node_modules/@metalsmith/collections/node_modules/lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", + "dev": true + }, "node_modules/@metalsmith/layouts": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/@metalsmith/layouts/-/layouts-2.4.0.tgz", @@ -4580,12 +4602,6 @@ "integrity": "sha512-lRLiIR9fSNpnP6TC4v8+4OU7oStC01esuNowdQ34L+Gk8e5Puoc88IqJ+XAY/B3Mn2ZKis8l8HX90oU8ivzUHg==", "dev": true }, - "node_modules/metalsmith-rename": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/metalsmith-rename/-/metalsmith-rename-1.0.0.tgz", - "integrity": "sha512-8AwQX0WEeRtE0aL7LzLJ9IPUZAe8gA1JqjrAU9sLRc+UWSIGa7S6tgUuWA87LgCMVQwc7xFjVCdIgDiM5rj9GA==", - "dev": true - }, "node_modules/metalsmith-sitemap": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/metalsmith-sitemap/-/metalsmith-sitemap-1.2.2.tgz", @@ -5604,6 +5620,15 @@ "node": ">= 0.8" } }, + "node_modules/read-metadata": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/read-metadata/-/read-metadata-1.0.0.tgz", + "integrity": "sha512-XJdiOrkzOlIac9vXNvgp/4I8qj9EPuHlbf/eoX2rusLFjdKjp0TQ82V3cj+AFjXBzzoZ1TaqAtHnGsR3UdO1Gw==", + "dev": true, + "dependencies": { + "yaml-js": "0.0.8" + } + }, "node_modules/read-pkg": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", @@ -7568,6 +7593,12 @@ "node": ">= 6" } }, + "node_modules/yaml-js": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/yaml-js/-/yaml-js-0.0.8.tgz", + "integrity": "sha512-XCqDFUhDO3yhT+Rb/inT3uiC8ekx2lXHDgDeXY8V0Lgkx4yEhzhxraYQxtuajydIrx8L8KmF9OeKCDlyCjvnMQ==", + "dev": true + }, "node_modules/yargs": { "version": "17.7.1", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz", @@ -8056,6 +8087,24 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "@metalsmith/collections": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@metalsmith/collections/-/collections-1.3.0.tgz", + "integrity": "sha512-RnTyDeDvlOPQ6/yisUeCVfy4gjPzImW9lDTP9gbQa1I5EAZ6kXrvlSnMxiIqqQ9/VPePv68TOXJRqkancfF2bA==", + "dev": true, + "requires": { + "lodash.get": "^4.4.2", + "read-metadata": "^1.0.0" + }, + "dependencies": { + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", + "dev": true + } + } + }, "@metalsmith/layouts": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/@metalsmith/layouts/-/layouts-2.4.0.tgz", @@ -11070,12 +11119,6 @@ } } }, - "metalsmith-rename": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/metalsmith-rename/-/metalsmith-rename-1.0.0.tgz", - "integrity": "sha512-8AwQX0WEeRtE0aL7LzLJ9IPUZAe8gA1JqjrAU9sLRc+UWSIGa7S6tgUuWA87LgCMVQwc7xFjVCdIgDiM5rj9GA==", - "dev": true - }, "metalsmith-sitemap": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/metalsmith-sitemap/-/metalsmith-sitemap-1.2.2.tgz", @@ -11832,6 +11875,15 @@ "unpipe": "1.0.0" } }, + "read-metadata": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/read-metadata/-/read-metadata-1.0.0.tgz", + "integrity": "sha512-XJdiOrkzOlIac9vXNvgp/4I8qj9EPuHlbf/eoX2rusLFjdKjp0TQ82V3cj+AFjXBzzoZ1TaqAtHnGsR3UdO1Gw==", + "dev": true, + "requires": { + "yaml-js": "0.0.8" + } + }, "read-pkg": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", @@ -13346,6 +13398,12 @@ "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", "dev": true }, + "yaml-js": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/yaml-js/-/yaml-js-0.0.8.tgz", + "integrity": "sha512-XCqDFUhDO3yhT+Rb/inT3uiC8ekx2lXHDgDeXY8V0Lgkx4yEhzhxraYQxtuajydIrx8L8KmF9OeKCDlyCjvnMQ==", + "dev": true + }, "yargs": { "version": "17.7.1", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.1.tgz", diff --git a/package.json b/package.json index f5f40e7..783c9cc 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ }, "author": "David Soulayrol ", "devDependencies": { + "@metalsmith/collections": "1.3.0", "@metalsmith/layouts": "2.4.0", "@metalsmith/markdown": "1.9.1", "@metalsmith/permalinks": "^2.4.0", @@ -38,7 +39,6 @@ "metalsmith": "^2.4.0", "metalsmith-assets": "^0.1.0", "metalsmith-groff": "^0.3.0", - "metalsmith-rename": "^1.0.0", "metalsmith-sitemap": "^1.2.2", "nodemon": "^2.0.12", "rimraf": "^3.0.2", diff --git a/scripts/metalsmith-web.js b/scripts/metalsmith-web.js index 0d8e0b1..ea57ef6 100644 --- a/scripts/metalsmith-web.js +++ b/scripts/metalsmith-web.js @@ -4,8 +4,8 @@ const config = require('./config.js') const groff = require('metalsmith-groff') const layouts = require('@metalsmith/layouts') const Metalsmith = require('metalsmith') +const collections = require('@metalsmith/collections') const markdown = require('@metalsmith/markdown') -const rename = require('metalsmith-rename') const permalinks = require('@metalsmith/permalinks') const sitemap = require('metalsmith-sitemap') const slug = require('slug') @@ -28,14 +28,13 @@ module.exports = new Metalsmith(config.paths.projectRoot) }) .source(config.paths.webSource) .destination(config.paths.webDestination) - .use(assets({ - source: './assets/' + (process.env.NODE_ENV || 'dev'), - destination: config.paths.webDestination - })) .use(groff({ preprocessors: ['tbl'], source: true })) + .use(collections({ + documents: { pattern: 'documents/**/*.md' } + })) .use(markdown({ gfm: false, headerIds: false, @@ -57,20 +56,30 @@ module.exports = new Metalsmith(config.paths.projectRoot) } } })) - .use(rename([ - [/\.njk$/, '.html'] - ])) .use(permalinks({ - pattern: 'documents/:title', - relative: 'folder', - // linksets: [ - // { - // match: { path: 'blogposts' }, - // pattern: 'blog/:date/:title', - // date: 'mmddyy' - // } - // ] - duplicatesFail: true + pattern: ':title', + linksets: [ + { + match: { collection: 'documents' }, + pattern: 'documents/:title', + duplicatesFail: true + } + ], + relative: false, + slug: { + remove: /[^a-z0-9- ]+/gi, + lower: true, + extend: { + "'": '' + } + } + })) + /* Assets are only installed after layouts and permalinks has been used, so + * that legacy HTML files are left untouched. + */ + .use(assets({ + source: './assets/' + (process.env.NODE_ENV || 'dev'), + destination: config.paths.webDestination })) .use(sitemap({ changefreq: 'yearly',