From a1dcb854b9db04ad434bf68bf16d43edb2b63f1e Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Fri, 15 Nov 2019 11:40:23 +1300 Subject: [PATCH] Extract fontawesome --- gatsby-browser.js | 2 +- gatsby-config.js | 44 ++++++++++++++++++++++++++++++++++++++++---- gatsby-ssr.js | 5 +++-- package.json | 1 + yarn.lock | 9 ++++++++- 5 files changed, 53 insertions(+), 8 deletions(-) diff --git a/gatsby-browser.js b/gatsby-browser.js index debe667..a0ac90f 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -1,6 +1,6 @@ require("prismjs/themes/prism-okaidia.css"); require("./src/theme/assets/scss/theme.scss"); -require('./src/theme/assets/fontawesome/js/all.js'); +require('./src/theme/assets/fontawesome/css/all.css'); require('./src/theme/assets/search/algolia.css'); const smoothScroll = require('smooth-scroll'); const Layout = require('./src/components/Layout').default; diff --git a/gatsby-config.js b/gatsby-config.js index db5c429..6864418 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,3 +1,5 @@ +const path = require('path'); + module.exports = { siteMetadata: { title: `SilverStripe Documentation`, @@ -39,7 +41,14 @@ module.exports = { resolve: 'gatsby-transformer-remark', options: { plugins: [ - 'gatsby-remark-prismjs', + { + resolve: `gatsby-remark-prismjs`, + options: { + aliases: { + ss: 'html', + } + } + }, `gatsby-remark-copy-linked-files`, { resolve: `gatsby-remark-images`, @@ -63,13 +72,40 @@ module.exports = { printRejected: false, whitelist: ['algolia-autocomplete'], ignore: ['prismjs/','docsearch.js/', 'src/theme/assets/search/algolia.css'], - //purgeOnly : ['components/', '/main.css', 'bootstrap/'], - } + content: [ + path.join(process.cwd(), '.cache/gatsby-source-git/**/*.md'), + ], + extractors: [, + { + extractor: class { + static extract(content) { + return content.match(/[A-Za-z0-9-_:\/]+/g) || []; + } + }, + extensions: ['js', 'ts', 'jsx', 'tsx', 'md', 'mdx'] + }, + { + extractor: class { + static extract(content) { + const selectors = [`file-alt`] + const matches = content.match(/icon(Brand)?: ([a-zA-Z0-9_-]+)/); + if (matches) { + const isBrand = typeof matches[1] !== 'undefined'; + selectors.push(isBrand ? `fab` : `fas`); + selectors.push(`fa-${matches[2]}`); + } + return selectors; + } + }, + extensions: ['md'] + }, + ] + }, }, { resolve: `gatsby-plugin-offline`, options: { - precachePages: [`/en/4/developer_guides/*`], + precachePages: [`/en/4/developer_guides/**`], }, } ], diff --git a/gatsby-ssr.js b/gatsby-ssr.js index 02ea649..17ba2ec 100644 --- a/gatsby-ssr.js +++ b/gatsby-ssr.js @@ -7,8 +7,9 @@ exports.wrapPageElement = ({ element, props }) => { exports.onRenderBody = ({ setPostBodyComponents }) => { setPostBodyComponents([ -