加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gatsby-node.js 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
const path = require('path');
exports.onCreateWebpackConfig = ({ rules, actions }) => {
actions.setWebpackConfig({
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules(?!\/@toast-ui\/doc)|bower_components(?!\/@toast-ui\/doc))/,
use: rules.js().use
}
]
}
});
};
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions;
return new Promise((resolve) => {
graphql(`
{
allNavigationJson {
edges {
node {
pid
type
}
}
}
}
`).then((result) => {
result.data.allNavigationJson.edges.forEach(({ node }) => {
const { pid, type } = node;
let filename = '';
if (type === 'example') {
// for static file using in iframe
filename = pid.replace('tutorial-', '');
}
createPage({
path: `/${pid}`,
component: path.resolve(`./src/templates/${type}-page.js`),
context: {
// Data passed to context is available
// in page queries as GraphQL variables.
id: pid,
filename
}
});
});
resolve();
});
});
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化