Skip to content

Commit

Permalink
fix: "Theme Variables" were not appearing on component pages (docs)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald committed Jan 14, 2025
1 parent 4ddc476 commit 64ccf2b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions www/utils/createPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,20 @@ async function createPages(graphql, actions, reporter) {

// you'll call `createPage` for each result
for (const { node } of pages) {
const componentDir = node.fields.slug.split('/')[0];
const variablesPath = path.resolve(__dirname, `../../src/${componentDir}/_variables.scss`);
const githubEditPath = `https://github.com/openedx/paragon/edit/master/src${node.internal.contentFilePath.split('src')[1]}`;
let scssVariablesData = {};

if (fs.existsSync(variablesPath)) {
// eslint-disable-next-line no-await-in-loop
scssVariablesData = await processComponentSCSSVariables(variablesPath, themesSCSSVariables);
}


Check failure on line 54 in www/utils/createPages.js

View workflow job for this annotation

GitHub Actions / tests

Trailing spaces not allowed
if (node.fields.source === 'components') {
// Check for a _variables.scss file for this component, e.g. src/Button/_variables.scss.
// If it exists, load the data:
let scssVariablesData = {};
if (node.internal.contentFilePath.endsWith('/README.md')) {
const variablesPath = node.internal.contentFilePath.replace('/README.md', '/_variables.scss');
if (fs.existsSync(variablesPath)) {
// eslint-disable-next-line no-await-in-loop
scssVariablesData = await processComponentSCSSVariables(variablesPath, themesSCSSVariables);
}
}

createPage({
// This is the slug you created before
// (or `node.frontmatter.slug`)
Expand All @@ -86,7 +89,6 @@ async function createPages(graphql, actions, reporter) {
context: {
id: node.id,
githubEditPath,
scssVariablesData,
frontmatter: {
title: node.frontmatter.title,
},
Expand Down

0 comments on commit 64ccf2b

Please sign in to comment.