0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00
verdaccio/website/gatsby-node.js
Juan Picado 3ad519f0c2 chore: website scaffolding (#1843)
* chore: upload gatsby website

* chore: update header

* chore: add background header

* chore: add ci for website

* Update ci-website.yml

* chore: update patch mach ci

* chore: update ci settings

* chore: update docker version
2021-04-09 17:54:10 +02:00

77 lines
2.1 KiB
JavaScript

/**
* Fix: react-🔥-dom patch is not detected.
* https://github.com/gatsbyjs/gatsby/issues/11934
*/
exports.onCreateWebpackConfig = ({ stage, actions }) => {
if (stage.startsWith('develop')) {
actions.setWebpackConfig({
resolve: {
alias: {
'react-dom': '@hot-loader/react-dom',
},
},
});
}
};
// You can delete this file if you're not using it
const path = require('path');
exports.createPages = ({ graphql, actions }) => {
const { createPage } = actions;
return new Promise((resolve, reject) => {
const docPageTemplate = path.resolve('src/templates/docPage.tsx');
resolve(
graphql(
`
query {
allMarkdownRemark {
edges {
node {
id
frontmatter {
title
}
html
fileAbsolutePath
}
}
}
}
`
).then((result) => {
const posts = result.data.allMarkdownRemark.edges;
posts.forEach(({ node }, index) => {
const fileAbsolutePath = node.fileAbsolutePath;
const parsedAbsolutedPath = path.parse(fileAbsolutePath);
if (fileAbsolutePath.match('translated_docs')) {
const pathCrowdin = `${__dirname}/crowdin/master/website/translated_docs/`;
const lng = parsedAbsolutedPath.dir.replace(pathCrowdin, '');
const id = node.id;
createPage({
path: `docs/${lng}/${parsedAbsolutedPath.name}.html`,
component: docPageTemplate,
context: {
id,
lng,
},
});
} else {
const id = node.id;
const lng = 'en';
createPage({
path: `docs/en/${parsedAbsolutedPath.name}.html`,
component: docPageTemplate,
context: {
id,
lng,
},
});
}
resolve();
});
})
);
});
};