fix: transform links with basepath

This commit is contained in:
2025-02-07 16:52:17 +01:00
parent 3a00e7c680
commit a5fe0a7054
5 changed files with 36 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import layouts from '@metalsmith/layouts'
import markdown from '@metalsmith/markdown'
import permalinks from '@metalsmith/permalinks'
import collections from '@metalsmith/collections'
import inPlace from '@metalsmith/in-place'
const __dirname = dirname(fileURLToPath(import.meta.url))
const t1 = performance.now()
@@ -36,14 +37,26 @@ Metalsmith(__dirname)
TZ: 'Europe/Paris',
})
.metadata(sitedata)
.use(inPlace({
pattern: '**/*.md',
transform: 'handlebars'
}))
.use(markdown())
.use(permalinks())
.use(collections({
nav: {
pattern: '**/*.html',
sortBy: 'nav_order'
sortBy: 'nav_order',
metadata: {
base: sitedata.site.basePath
}
}
}))
.use(permalinks())
.use(function addBasePathToCollection(files) {
Object.values(files).forEach(file => {
file.basePath = sitedata.site.basePath;
});
})
.use(layouts({
directory: 'layouts',
default: 'default.hbs',