Skip to content

Commit

Permalink
chore: Resolve translated yaml and mdx in install plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
LizBaker committed Oct 23, 2024
1 parent 8081e57 commit 6e64a4a
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions plugins/gatsby-source-install-config/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { pick } = require('lodash');

const locale = process.env.BUILD_LANG;

exports.sourceNodes = ({
actions,
createNodeId,
Expand All @@ -8,7 +10,12 @@ exports.sourceNodes = ({
}) => {
const { createNode } = actions;

const configYamlNodes = getNodesByType('ConfigYaml');
const configYamlNodes =
locale === 'en'
? getNodesByType('ConfigYaml')
: getNodesByType(
`${locale.charAt(0).toUpperCase() + locale.slice(1)}Yaml`
);

configYamlNodes.forEach((configYamlNode) => {
const {
Expand Down Expand Up @@ -138,7 +145,7 @@ exports.createResolvers = ({ createResolvers }) => {
resolve: async (source, _args, context) => {
const { nodeModel } = context;

const { entries: allMdx } = await nodeModel.findAll({
const { entries: allEnglishMdx } = await nodeModel.findAll({
type: 'Mdx',
query: {
filter: {
Expand All @@ -149,6 +156,18 @@ exports.createResolvers = ({ createResolvers }) => {
},
});

const { entries: allTranslatedMdx } = await nodeModel.findAll({
type: 'Mdx',
query: {
filter: {
fileAbsolutePath: {
regex: `/src/i18n/install/${locale}/${source.agentName.toLowerCase()}/`,
},
},
},
});

const allMdx = locale === 'en' ? allEnglishMdx : allTranslatedMdx;
const mdxFiles = Array.from(allMdx);

const steps = source.steps.map((step) =>
Expand Down

0 comments on commit 6e64a4a

Please sign in to comment.