Updated the toolchain for a better permalinks configuration.
This commit is contained in:
parent
f840436ea8
commit
44690b58d5
11 changed files with 99 additions and 32 deletions
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue