Skip to content

Commit

Permalink
fix(clayui.com): fixes error when generating slugs for documents insi…
Browse files Browse the repository at this point in the history
…de packages

This allows us to create documents without the README or is at the root of the package, we can move the documents to the docs folder of each package.
  • Loading branch information
matuzalemsteles committed Jul 27, 2021
1 parent a75dab6 commit 5e00f5a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions clayui.com/gatsby/onCreateNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ module.exports = exports.onCreateNode = ({actions, getNode, node}) => {
}

if (!slug) {
// Create a slug for files that are in component packages, README
// files or files inside the docs folder.
if (sourceInstanceName === 'packages' && title) {
const fileName = path.basename(relativePath).split('.')[0];

Expand All @@ -86,16 +88,24 @@ module.exports = exports.onCreateNode = ({actions, getNode, node}) => {
}
}

if (relativePath.includes('docs')) {
// Create the slug for files are inside the content folder that
// belong to clayui.com package.
if (
sourceInstanceName === 'content' &&
relativePath.includes('docs')
) {
if (relativePath.endsWith('.md')) {
slug = relativePath.replace('.md', '.html');
} else {
slug = relativePath.replace('.mdx', '.html');
}
}

if (mainTabURL) {
slug = generateTabSlug(slug, mainTabURL);
}
// Create the slug for any file that contains `docs` as part of
// the path, it may be inside the clayui.com package or in the
// component packages.
if (mainTabURL && relativePath.includes('docs')) {
slug = generateTabSlug(relativePath, mainTabURL);
}

if (relativePath.includes('blog')) {
Expand Down

0 comments on commit 5e00f5a

Please sign in to comment.