From 3ec468be389123a6cc840d4fff0116ffd411a42b Mon Sep 17 00:00:00 2001 From: Ahmad Abdolsaheb Date: Wed, 13 Jan 2021 16:12:32 +0300 Subject: [PATCH] feat: optimize head tags (#40630) Co-authored-by: moT01 <20648924+moT01@users.noreply.github.com> --- client/gatsby-ssr.js | 73 +---------- client/i18n/locales/chinese/translations.json | 1 + client/i18n/locales/english/translations.json | 3 +- client/i18n/locales/espanol/translations.json | 1 + client/i18n/translations-schema.js | 6 +- client/src/head/index.js | 9 -- client/src/head/meta.js | 34 ------ client/src/head/preloads.js | 11 -- client/src/head/styleSheets.js | 3 - client/src/html.js | 2 - client/utils/tags.js | 85 +++++++++++++ cypress/integration/tags.js | 115 ++++++++++++++++++ 12 files changed, 210 insertions(+), 133 deletions(-) delete mode 100644 client/src/head/index.js delete mode 100644 client/src/head/meta.js delete mode 100644 client/src/head/preloads.js delete mode 100644 client/src/head/styleSheets.js create mode 100644 client/utils/tags.js create mode 100644 cypress/integration/tags.js diff --git a/client/gatsby-ssr.js b/client/gatsby-ssr.js index 91a115123c..041dda0934 100644 --- a/client/gatsby-ssr.js +++ b/client/gatsby-ssr.js @@ -4,10 +4,9 @@ import { Provider } from 'react-redux'; import { I18nextProvider } from 'react-i18next'; import i18n from './i18n/config'; -import headComponents from './src/head'; import { createStore } from './src/redux/createStore'; - import layoutSelector from './utils/gatsby/layoutSelector'; +import { getheadTagComponents, getPostBodyComponents } from './utils/tags'; const store = createStore(); @@ -23,26 +22,6 @@ wrapRootElement.propTypes = { element: PropTypes.any }; -// TODO: put these in a common utils file. -const mathJaxCdn = { - address: - 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/' + - '2.7.4/MathJax.js?config=TeX-AMS_HTML', - id: 'mathjax', - key: 'mathjax', - type: 'text/javascript' -}; - -const stripeScript = { - address: 'https://js.stripe.com/v3/', - id: 'stripe-js', - key: 'stripe-js', - type: 'text/javascript' -}; - -const challengeRE = new RegExp('/learn/[^/]+/[^/]+/[^/]+/?$'); -const donateRE = new RegExp('/donate/?$'); - export const wrapPageElement = layoutSelector; export const onRenderBody = ({ @@ -50,52 +29,6 @@ export const onRenderBody = ({ setHeadComponents, setPostBodyComponents }) => { - setHeadComponents([...headComponents]); - const scripts = [ -