diff --git a/gatsby-config.ts b/gatsby-config.ts index 103acc2f..3b81e2b1 100644 --- a/gatsby-config.ts +++ b/gatsby-config.ts @@ -58,7 +58,6 @@ const gatsbyConfig: GatsbyConfig = { 'gatsby-plugin-image', 'gatsby-plugin-sharp', 'gatsby-transformer-sharp', - 'gatsby-plugin-lodash', 'gatsby-plugin-sitemap', { resolve: 'gatsby-plugin-manifest', diff --git a/gatsby-node.ts b/gatsby-node.ts index 859bc7e2..106af3ec 100644 --- a/gatsby-node.ts +++ b/gatsby-node.ts @@ -1,7 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import type { GatsbyNode } from 'gatsby' import path from 'path' -import _ from 'lodash' // graphql function doesn't throw an error so we have to check to check for the result.errors to throw manually const wrapper = (promise: any) => @@ -22,13 +21,13 @@ export const onCreateNode: GatsbyNode['onCreateNode'] = ({ node, actions }: any) Object.prototype.hasOwnProperty.call(node.frontmatter, 'slug') ) { // If the frontmatter has a "slug", use it - slug = `/${_.kebabCase(node.frontmatter.slug)}` + slug = `/${convertToKebabCase(node.frontmatter.slug)}` } else if ( Object.prototype.hasOwnProperty.call(node, 'frontmatter') && Object.prototype.hasOwnProperty.call(node.frontmatter, 'title') ) { // If not derive a slug from the "title" in the frontmatter - slug = `/${_.kebabCase(node.frontmatter.title)}` + slug = `/${convertToKebabCase(node.frontmatter.title)}` } createNodeField({ node, name: 'slug', value: slug }) } @@ -80,3 +79,9 @@ export const createPages: GatsbyNode['createPages'] = }) }) } + +const convertToKebabCase = (text: string) => + text + .replace(/([a-z])([A-Z])/g, '$1-$2') + .replace(/[\s_]+/g, '-') + .toLowerCase() diff --git a/package-lock.json b/package-lock.json index 8f531c64..3862c09d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,6 @@ "gatsby": "5.13.1", "gatsby-plugin-google-analytics": "5.13.0", "gatsby-plugin-image": "3.13.0", - "gatsby-plugin-lodash": "6.13.0", "gatsby-plugin-manifest": "5.13.0", "gatsby-plugin-mdx": "5.13.0", "gatsby-plugin-offline": "6.13.0", @@ -28,7 +27,6 @@ "gatsby-transformer-sharp": "5.13.0", "jquery": "3.7.1", "justifiedGallery": "3.8.1", - "lodash": "4.17.21", "polished": "4.2.2", "react": "18.2.0", "react-dom": "18.2.0", @@ -14069,22 +14067,6 @@ "node": ">=14.14" } }, - "node_modules/gatsby-plugin-lodash": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/gatsby-plugin-lodash/-/gatsby-plugin-lodash-6.13.0.tgz", - "integrity": "sha512-6dgiN3gLVa/X7mUY34ivQxx3g81yhBc3A+QKx8h55aIGi0925P27Yg+X7EXK81VAjGlghxnAxOrzzXq+ciwJKQ==", - "dependencies": { - "@babel/runtime": "^7.20.13", - "babel-plugin-lodash": "^3.3.4", - "lodash-webpack-plugin": "^0.11.6" - }, - "engines": { - "node": ">=18.0.0" - }, - "peerDependencies": { - "gatsby": "^5.0.0-next" - } - }, "node_modules/gatsby-plugin-manifest": { "version": "5.13.0", "resolved": "https://registry.npmjs.org/gatsby-plugin-manifest/-/gatsby-plugin-manifest-5.13.0.tgz", @@ -18135,17 +18117,6 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, - "node_modules/lodash-webpack-plugin": { - "version": "0.11.6", - "resolved": "https://registry.npmjs.org/lodash-webpack-plugin/-/lodash-webpack-plugin-0.11.6.tgz", - "integrity": "sha512-nsHN/+IxZK/C425vGC8pAxkKJ8KQH2+NJnhDul14zYNWr6HJcA95w+oRR7Cp0oZpOdMplDZXmjVROp8prPk7ig==", - "dependencies": { - "lodash": "^4.17.20" - }, - "peerDependencies": { - "webpack": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.1.0" - } - }, "node_modules/lodash._reinterpolate": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", diff --git a/package.json b/package.json index 0fb14b85..a76a1faa 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "gatsby": "5.13.1", "gatsby-plugin-google-analytics": "5.13.0", "gatsby-plugin-image": "3.13.0", - "gatsby-plugin-lodash": "6.13.0", "gatsby-plugin-manifest": "5.13.0", "gatsby-plugin-mdx": "5.13.0", "gatsby-plugin-offline": "6.13.0", @@ -52,7 +51,6 @@ "gatsby-transformer-sharp": "5.13.0", "jquery": "3.7.1", "justifiedGallery": "3.8.1", - "lodash": "4.17.21", "polished": "4.2.2", "react": "18.2.0", "react-dom": "18.2.0",