From e23d15c40332061ae1918bfdf4f91dfeb80eaa97 Mon Sep 17 00:00:00 2001 From: Seth Falco Date: Sat, 18 May 2024 09:44:07 +0100 Subject: [PATCH] chore: optimize svgos for inline html usage --- docusaurus.config.js | 6 +++--- src/pages/index.js | 2 +- src/plugins/configure-svgo.js | 34 ++++++++++++++++++++++++------- src/vectors/logo.svg | 6 +++--- src/vectors/svgo_hackerman.svg | 2 +- src/vectors/svgo_integrations.svg | 3 +-- src/vectors/svgo_oss.svg | 2 +- src/vectors/svgo_trixie.svg | 2 +- 8 files changed, 38 insertions(+), 19 deletions(-) diff --git a/docusaurus.config.js b/docusaurus.config.js index 5a7f858..6b6b327 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -12,14 +12,14 @@ const { themes } = require('prism-react-renderer'); /** * Config for Docusaurus. * + * $.tagline is undefined, as our copy is specified in the code instead. * $.themeConfig.navbar.logo is undefined as this is configured with a custom component. - * $.themeConfig.footer.style is ignored as this is overriden with custom CSS. + * $.themeConfig.footer.style is ignored as this is overridden with custom CSS. * * @type {Config} */ const config = { title: "SVGO", - tagline: "A Node.js library and command-line application to optimize vectors.", favicon: "img/favicon.ico", url: "https://svgo.dev", baseUrl: "/", @@ -32,7 +32,7 @@ const config = { i18n: { defaultLocale: "en", locales: [ - "en" + "en" ], }, markdown: { diff --git a/src/pages/index.js b/src/pages/index.js index 01f72a6..3f95691 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -57,7 +57,7 @@ export default function Home() { return ( - +
diff --git a/src/plugins/configure-svgo.js b/src/plugins/configure-svgo.js index f9d5302..9f8044e 100644 --- a/src/plugins/configure-svgo.js +++ b/src/plugins/configure-svgo.js @@ -23,13 +23,33 @@ function configureSvgo() { }); const svgoConfig = rule.oneOf[0].use[0].options.svgoConfig; - svgoConfig.plugins.push({ - name: "prefixIds", - params: { - delim: "", - prefix: (_, info) => path.parse(info.path).name - } - }); + svgoConfig.plugins = [ + { + ...svgoConfig.plugins[0], + params: { + overrides: { + ...svgoConfig.plugins[0].params.overrides, + mergePaths: { + noSpaceAfterFlags: true + } + } + } + }, + { + name: "prefixIds", + params: { + delim: "", + prefix: (_, info) => path.parse(info.path).name + } + }, + { + name: "removeXlink", + params: { + includeLegacy: true + } + }, + "removeXMLNS" + ]; return { mergeStrategy: { diff --git a/src/vectors/logo.svg b/src/vectors/logo.svg index a33d7e8..c0167b6 100644 --- a/src/vectors/logo.svg +++ b/src/vectors/logo.svg @@ -1,4 +1,4 @@ - + @@ -6,8 +6,8 @@ - + - + diff --git a/src/vectors/svgo_hackerman.svg b/src/vectors/svgo_hackerman.svg index b5e13dc..759187b 100644 --- a/src/vectors/svgo_hackerman.svg +++ b/src/vectors/svgo_hackerman.svg @@ -1,4 +1,4 @@ - + diff --git a/src/vectors/svgo_integrations.svg b/src/vectors/svgo_integrations.svg index f115160..e95602e 100644 --- a/src/vectors/svgo_integrations.svg +++ b/src/vectors/svgo_integrations.svg @@ -1,5 +1,4 @@ - +