Skip to content

Commit

Permalink
내부 페이지 url 변경
Browse files Browse the repository at this point in the history
Signed-off-by: KIM GYUHO <kyuhokim12@gmail.com>
  • Loading branch information
GyuHo123 authored Jan 19, 2024
1 parent 1380556 commit 1d9c341
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,27 @@ exports.onCreateNode = ({ node, getNode, actions, reporter }) => {

if (node.internal.type === `Mdx`) {
const parent = getNode(node.parent);
const title = node.frontmatter.title || startCase(parent.name)
const title = node.frontmatter.title || startCase(parent.name);

let value = node.frontmatter.slug;
if(!value && parent.relativePath){
value = parent.relativePath.replace(parent.ext, '');
let slugValue = node.frontmatter.slug;
if (!slugValue && parent.relativePath) {
slugValue = parent.relativePath.replace(parent.ext, '');
slugValue = slugValue.replace('/JHelper/', '/');
}
if (!value) {
reporter.panic(`Can not create node with title: ${title} there is no relative path or frontmatter to set the "slug" field`);

if (!slugValue) {
reporter.panic(`Cannot create node with title: ${title}, there is no relative path or frontmatter to set the "slug" field`);
return;
}

if (value === 'index') {
value = '';
if (slugValue === 'index') {
slugValue = '';
}

createNodeField({
name: `slug`,
node,
value: `/${value}`
value: `/${slugValue}`
});

createNodeField({
Expand Down

0 comments on commit 1d9c341

Please sign in to comment.