Skip to content

Commit

Permalink
Fixes file.permalink for root directoryIndex files from '.' to ''
Browse files Browse the repository at this point in the history
  • Loading branch information
webketje committed Dec 28, 2024
1 parent 5f2fca3 commit 3d975e5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,12 @@ function permalinks(options) {
}

// add to permalink data for use in links in templates
let permalink = path.posix.join('.', ppath.replace(/\\/g, '/'))
if (normalizedOptions.trailingSlash) {
permalink = path.posix.join(permalink, './')
const { join, normalize } = path.posix
// files matched for permalinking that are already at their destination (/index.html) have an empty string permalink ('')
// normalize('') results in '.', which we don't want here
let permalink = ppath.length ? normalize(ppath) : ppath
if (permalink.length && normalizedOptions.trailingSlash) {
permalink = join(permalink, './')
}

// contrary to the 2.x "path" property, the permalink property does not override previously set file metadata
Expand Down

0 comments on commit 3d975e5

Please sign in to comment.