Skip to content

Commit

Permalink
fix: spotted broken pages
Browse files Browse the repository at this point in the history
  • Loading branch information
timwessman committed Nov 13, 2024
1 parent 383317d commit ba2ebdc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
46 changes: 28 additions & 18 deletions site/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,41 @@ exports.createPages = async ({ actions, graphql }) => {
throw new Error('Failed to fetch MDX data');
}

const brokenPages = [
'/release-3.11.0/components/phone-input',
'/release-3.11.0/components/dropdown',
];

// Create pages dynamically
result.data.allMdx.edges.forEach(({ node }) => {
const gitRemote = node.parent?.gitRemote?.ref;
const pathWithVersion = path.join('/', gitRemote || '', node.frontmatter.slug);

try {
const pageTemplate = require.resolve('./src/components/ContentLayoutWrapper.js');
const contentPath = './src/docs/' + node.parent.relativePath.replace('site/src/docs/', '');
if (!brokenPages.includes(pathWithVersion)) {
try {
const pageTemplate = require.resolve('./src/components/ContentLayoutWrapper.js');
const contentPath = './src/docs/' + node.parent.relativePath.replace('site/src/docs/', '');

console.log('createPage() ' + gitRemote + ' ' + contentPath);
console.log('createPage() ' + gitRemote + ' ' + contentPath);

const pageContent = gitRemote
? require.resolve(`./.cache/gatsby-source-git/docs-${gitRemote}/${node.parent.relativePath}`)
: require.resolve(contentPath);
const pageContent = gitRemote
? require.resolve(`./.cache/gatsby-source-git/docs-${gitRemote}/${node.parent.relativePath}`)
: require.resolve(contentPath);

const pathWithVersion = path.join('/', gitRemote || '', node.frontmatter.slug);
createPage({
component: `${pageTemplate}?__contentFilePath=${pageContent}`,
path: pathWithVersion,
context: {
id: node.id,
frontmatter: { ...node.frontmatter, slug: pathWithVersion },
},
});
} catch (e) {
console.error(e);
createPage({
component: `${pageTemplate}?__contentFilePath=${pageContent}`,
path: pathWithVersion,
context: {
id: node.id,
frontmatter: { ...node.frontmatter, slug: pathWithVersion },
},
});
} catch (e) {
console.error(e);
}
}
else {
console.log('Skip', pathWithVersion);
}
});
};
2 changes: 1 addition & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "site",
"private": true,
"description": "Documentation for Helsinki Design System",
"version": "3.11.0",
"version": "4.0.0",
"workspaces": {
"nohoist": [
"gatsby",
Expand Down
2 changes: 1 addition & 1 deletion site/src/data/versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
"4.0.0",
"4.0.0-beta"
"3.11.0"
]

0 comments on commit ba2ebdc

Please sign in to comment.