Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.onCreateNode = ({ node, getNode, boundActionCreators }) => {
const { createNodeField } = boundActionCreators;
if (node.internal.type === 'MarkdownRemark') {
// I put the index.js with index.md. Therefore, I have to give it specific path
const slug = createFilePath({ node, getNode, basePath: 'pages' });
// const slug = createFilePath({ node, getNode, basePath: 'pages' }).concat('index.md');
// console.log(`slug for ${node.id} : ${slug}`);
createNodeField({
node,
name: 'slug',
value: slug,
});
}
};
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions;
// We only want to operate on `Mdx` nodes. If we had content from a
// remote CMS we could also check to see if the parent node was a
// `File` node here
if (node.internal.type === 'Mdx') {
// generate path from frontmatter or from node path
const basePath = createFilePath({ node, getNode });
const nodePath =
node.internal.frontmatter && node.internal.frontmatter.path
? node.internal.frontmatter.path
: basePath;
createNodeField({
name: 'path',
node,
value: nodePath,
});
// generate article type from frontmatter or from node path
const baseType = basePath.split('/')[1] || 'page';
const nodeType =
node.internal.frontmatter && node.internal.frontmatter.type
? node.internal.frontmatter.type
: baseType;
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions;
// We only want to operate on `Mdx` nodes. If we had content from a
// remote CMS we could also check to see if the parent node was a
// `File` node here
if (node.internal.type === "Mdx") {
const value = createFilePath({ node, getNode });
createNodeField({
// Name of the field you are adding
name: "slug",
// Individual MDX node
node,
// Generated value based on filepath with "blog" prefix
value: `/blog${value}`
});
}
};
if (node.internal.type !== `MarkdownRemark` && node.internal.type !== `QiitaPost`) {
return
}
const [
slug,
title,
date,
excerpt,
tags,
thumbnail,
] =
node.internal.type === `MarkdownRemark`
? [
node.frontmatter.slug || createFilePath({ node, getNode }), // 記事でURL指定があればそちらを優先する
node.frontmatter.title,
node.frontmatter.date,
_excerptMarkdown(node.rawMarkdownBody, 120),
node.frontmatter.tags,
node.frontmatter.thumbnail
]
:[
`/${node.id}/`,
node.title,
node.created_at,
_excerptHtml(node.rendered_body, 120),
[...(node.tags.map(tag => tag.name) || []), 'Qiita'], // Qiitaタグを追加
undefined,
]
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions
fmImagesToRelative(node) // convert image paths for gatsby images
if (node.internal.type === `MarkdownRemark`) {
const value = createFilePath({ node, getNode })
createNodeField({
name: `slug`,
node,
value,
})
}
}
exports.onCreateNode = ({
node, actions, getNode, createNodeId,
}) => {
const { createNodeField, createNode } = actions;
if (node.internal.type === 'MarkdownRemark') {
const value = createFilePath({ node, getNode });
createNodeField({
name: 'slug',
node,
value,
});
}
if (node.internal.type !== 'TocYaml') {
return;
}
const fieldData = {
label: node.label,
isHeader: node.isHeader,
path: node.path,
childItems: node.childItems || null,
exports.onCreateNode = ({ node, getNode, actions }) => {
const { createNodeField } = actions;
if (node.internal.type === 'MarkdownRemark') {
createNodeField({
node,
name: 'slug',
value: createFilePath({ node, getNode }),
});
}
};
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions
if (node.internal.type === `MarkdownRemark`) {
const value = createFilePath({ node, getNode })
createNodeField({
name: `slug`,
node,
value,
})
}
}
exports.onCreateNode = ({ node, boundActionCreators, getNode }) => {
const { createNodeField } = boundActionCreators
if (node.internal.type === `MarkdownRemark`) {
const value = createFilePath({ node, getNode })
createNodeField({
name: `slug`,
node,
value,
})
}
}
exports.onCreateNode = ({ node, boundActionCreators, getNode }) => {
const { createNodeField } = boundActionCreators
if (node.internal.type === `MarkdownRemark`) {
const value = createFilePath({ node, getNode })
createNodeField({
name: `slug`,
node,
value,
})
}
}