✏️ 正在编辑: gatsby-node.js
路径:
/opt/alt/alt-nodejs12/root/usr/lib/node_modules/npm/docs/gatsby-node.js
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
const {createFilePath} = require('gatsby-source-filesystem') const path = require('path') exports.onCreateNode = ({node, getNode, actions}) => { const {createNodeField} = actions if (node.internal.type === 'MarkdownRemark') { const slug = createFilePath({node, getNode, basePath: 'content', trailingSlash: false}) createNodeField({ node, name: 'slug', value: slug }) } } exports.createPages = ({graphql, actions}) => { const {createPage} = actions return graphql(` { allMarkdownRemark { edges { node { id fields { slug } html } } } } `).then(result => { result.data.allMarkdownRemark.edges.forEach(({node}) => { createPage({ path: node.fields.slug, component: path.resolve('./src/templates/Page.js'), context: { slug: node.fields.slug } }) }) }) }
💾 保存文件
← 返回文件管理器