fix: match production URL format and fix OG URL
- Use front-matter title for post slug (not filename) - Remove /posts/ prefix from URLs to match production - Remove /pages/ prefix from page URLs to match production - Fix OG URL on index page (no longer shows .html extension) - Remove dots from slugs (fixes T.I.L. posts being files not dirs) - Collapse consecutive dashes in slugs - Remove / from slug character class (prevents URL paths in slugs) - Skip index.html in permalink plugin (already has correct path from pagination) Production URL format: /YYYY-MM-DD-full-title-slug/
This commit is contained in:
1 parent
b21390b1a4
commit
63a171aefd
2 files changed
+13
-25
No files matched your search
+3
-14
@@ -69,14 +69,10 @@ function permalinks(options) {
|
||||
if (key === 'date' && data._filenameDate) {
|
||||
return formatDate(data._filenameDate);
|
||||
}
|
||||
// For title in permalink, use _filenameTitle if available (to match source filenames)
|
||||
if (key === 'title' && data._filenameTitle) {
|
||||
return slugify(data._filenameTitle);
|
||||
}
|
||||
if (value instanceof Date) {
|
||||
return formatDate(value);
|
||||
}
|
||||
return slugify(value.toString());
|
||||
return slugify(value.toString()).replace(/-+/, "-");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -131,14 +127,8 @@ function permalinks(options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// For posts: preserve the "posts/" prefix
|
||||
// For other files: use the pattern as-is
|
||||
|
||||
let sourcePrefix = "";
|
||||
if (file.startsWith("posts/")) {
|
||||
sourcePrefix = "posts/";
|
||||
} else if (file.startsWith("pages/")) {
|
||||
sourcePrefix = "pages/";
|
||||
}
|
||||
|
||||
// Replace pattern placeholders
|
||||
let result = replacePattern(pattern, data);
|
||||
@@ -155,8 +145,7 @@ function permalinks(options) {
|
||||
}
|
||||
}
|
||||
|
||||
// Prepend source directory prefix
|
||||
data.permalink = sourcePrefix + result;
|
||||
data.permalink = result;
|
||||
|
||||
// Set path metadata for templates (permalink without index.html)
|
||||
if (data.permalink.endsWith("/index.html")) {
|
||||
|
||||
Reference in new issue
Block a user