Skip to content

Commit

Permalink
refactor: deleted old logic to search SCSS variables
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Mar 15, 2023
1 parent 56ccf7b commit 52a854e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 150 deletions.
12 changes: 1 addition & 11 deletions www/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const css = require('css');

const fs = require('fs');
const { INSIGHTS_PAGES } = require('./src/config');
const { getThemesSCSSVariables, processComponentSCSSVariables } = require('./theme-utils');

exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
Expand Down Expand Up @@ -97,14 +96,10 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
// Create component detail pages.
const components = result.data.allMdx.edges;

const themesSCSSVariables = await getThemesSCSSVariables();

// you'll call `createPage` for each result
// eslint-disable-next-line no-restricted-syntax
for (const { node } of components) {
const componentDir = node.slug.split('/')[0];
const variablesPath = path.resolve(__dirname, `../src/${componentDir}/_variables.scss`);
let scssVariablesData = {};
const cssVariablesData = [];

const pathToComponents = fs.readdirSync(`../src/${componentDir}`);
Expand All @@ -122,11 +117,6 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
}
});

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 @@ -136,7 +126,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
// You can use the values in this context in
// our page layout component
context: {
id: node.id, components: node.frontmatter.components || [], scssVariablesData, cssVariablesData,
id: node.id, components: node.frontmatter.components || [], cssVariablesData,
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion www/src/templates/component-page-template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default function PageTemplate({

const getTocData = () => {
const tableOfContents = JSON.parse(JSON.stringify(mdx.tableOfContents));
if (cssVariablesData.length && !tableOfContents.items?.includes()) {
if (cssVariablesData?.length && !tableOfContents.items?.includes()) {
tableOfContents.items?.push({
title: cssVariablesTitle,
url: `#${cssVariablesUrl}`,
Expand Down
138 changes: 0 additions & 138 deletions www/theme-utils.js

This file was deleted.

0 comments on commit 52a854e

Please sign in to comment.