Open mnaoumov opened 5 months ago
That comes from quartz parsing Aliases with path functions. (such as path.posix.join()
)
I don't think Quartz should parse Aliases as filenames (L19 below). But also they should respect the filename formats as they could be actual filenames (aliases means other name for the file after all ?)
But damn, i don't know-
If still parsed as filenames, im not sure but that could also lead to a potential other issue when putting slashes and paths like:
---
- "../someAlias"
- "C:\SomeOtherAlias"
---
This is due to the path.posix.join()
joining path with alias without any kind of input validation. Therefore the resulting path could change directory in the above case. (Not tested.)
We can think about something more like that:
const aliases = file.data.frontmatter?.aliases || [] // replaced ?? by || covering more error cases falling back on []
const slugs = aliases.map((alias) => (
dir.endsWith("/")
? String(dir)+String(alias)
: String(dir)+"/"+String(alias)
) as FullSlug)
that doesn't work. The code should be:
const slugs: FullSlug[] = aliases.map((alias) => {
console.log(alias)
const aliasWithNoInvalidFileSystemCharacters = alias.replace(/[\<\>\?\|\:]/g, '-');
return path.posix.join(dir, aliasWithNoInvalidFileSystemCharacters) as FullSlug
});
Note that this also converts Linux path, which is unnecessary.
Describe the bug
If you have an alias that cannot represent a file name, emit fails
To Reproduce
Note.md
Quartz
Failed to emit from plugin `AliasRedirects`: ENOENT: no such file or directory
Expected behavior
The site builds without error
Screenshots and Source
N/A
Desktop (please complete the following information):
node
Version: v20.11.0npm
version: v10.2.4Additional context
N/A