Skip to content

Commit 4f5c110

Browse files
committed
Fix the blog redirect
1 parent 1a98da7 commit 4f5c110

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

gatsby-node.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,13 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
124124
process.exit(1);
125125
}
126126

127+
const toPath = slug.startsWith('/') ? slug : `/${slug}`
128+
127129
redirectToSlugMap[fromPath] = slug;
128130
createRedirect({
129131
fromPath: `/${fromPath}`,
130132
redirectInBrowser: true,
131-
toPath: `/${slug}`,
133+
toPath,
132134
});
133135
});
134136
}
@@ -189,7 +191,7 @@ exports.onCreateNode = ({node, boundActionCreators, getNode}) => {
189191
const day = match[3];
190192
const filename = match[4];
191193

192-
slug = `blog/${year}/${month}/${day}/${filename}.html`;
194+
slug = `/blog/${year}/${month}/${day}/${filename}.html`;
193195

194196
const date = new Date(year, month - 1, day);
195197

0 commit comments

Comments
 (0)