From 88893b18cf26bb0c81f21d42c788b004462d8b70 Mon Sep 17 00:00:00 2001 From: Aileen Nowak Date: Thu, 6 Jun 2019 17:52:24 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Use=20styles=20passed=20into=20code?= =?UTF-8?q?injection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs #22 - Update gatsby-source-ghost@3.4.0 which includes the new node fiels `codeinjection_styles` - Inject styles with react-helmet into - Layout for site codeinjection - Post template for post codeinjection - Page template for page codeinjection --- package.json | 4 +- src/components/common/Layout.js | 1 + src/templates/page.js | 4 + src/templates/post.js | 4 + src/utils/fragments.js | 3 + yarn.lock | 158 ++++++++++++++++++++++++++------ 6 files changed, 145 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index dcddc9b7d..af1d4b7ab 100755 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@tryghost/helpers": "1.1.5", "@tryghost/helpers-gatsby": "1.0.8", "cheerio": "1.0.0-rc.3", - "gatsby": "2.8.2", + "gatsby": "2.8.5", "gatsby-awesome-pagination": "0.3.4", "gatsby-image": "2.1.2", "gatsby-plugin-advanced-sitemap": "1.0.6", @@ -47,7 +47,7 @@ "gatsby-plugin-react-helmet": "3.0.12", "gatsby-plugin-sharp": "2.1.3", "gatsby-source-filesystem": "2.0.38", - "gatsby-source-ghost": "3.3.4", + "gatsby-source-ghost": "3.4.0", "gatsby-transformer-sharp": "2.1.21", "lodash": "4.17.11", "react": "16.8.6", diff --git a/src/components/common/Layout.js b/src/components/common/Layout.js index ab99fbdfd..6218a8625 100644 --- a/src/components/common/Layout.js +++ b/src/components/common/Layout.js @@ -27,6 +27,7 @@ const DefaultLayout = ({ data, children, bodyClass, isHome }) => { <> + diff --git a/src/templates/page.js b/src/templates/page.js index 47d71dcbd..da18fc688 100755 --- a/src/templates/page.js +++ b/src/templates/page.js @@ -1,6 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import { graphql } from 'gatsby' +import { Helmet } from 'react-helmet' import { Layout } from '../components/common' import { MetaData } from '../components/common/meta' @@ -21,6 +22,9 @@ const Page = ({ data, location }) => { location={location} type="website" /> + + +
diff --git a/src/templates/post.js b/src/templates/post.js index 285cc7ed0..21a3ce556 100755 --- a/src/templates/post.js +++ b/src/templates/post.js @@ -1,6 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import { graphql } from 'gatsby' +import { Helmet } from 'react-helmet' import { Layout } from '../components/common' import { MetaData } from '../components/common/meta' @@ -21,6 +22,9 @@ const Post = ({ data, location }) => { location={location} type="article" /> + + +
diff --git a/src/utils/fragments.js b/src/utils/fragments.js index 95faf0722..970193481 100644 --- a/src/utils/fragments.js +++ b/src/utils/fragments.js @@ -123,6 +123,7 @@ export const ghostPostFields = graphql` page codeinjection_foot codeinjection_head + codeinjection_styles comment_id } ` @@ -210,6 +211,7 @@ export const ghostPageFields = graphql` page codeinjection_foot codeinjection_head + codeinjection_styles comment_id } ` @@ -228,6 +230,7 @@ export const ghostSettingsFields = graphql` timezone codeinjection_head codeinjection_foot + codeinjection_styles navigation { label url diff --git a/yarn.lock b/yarn.lock index 6655760c9..236e0d0c7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1464,16 +1464,17 @@ auto-bind@^2.0.0: dependencies: "@types/react" "^16.8.12" -autoprefixer@^9.4.3: - version "9.5.1" - resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-9.5.1.tgz#243b1267b67e7e947f28919d786b50d3bb0fb357" - integrity sha512-KJSzkStUl3wP0D5sdMlP82Q52JLy5+atf2MHAre48+ckWkXgixmfHyWmA77wFDy6jTHU6mIgXv6hAQ2mf1PjJQ== +autoprefixer@^9.6.0: + version "9.6.0" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-9.6.0.tgz#0111c6bde2ad20c6f17995a33fad7cf6854b4c87" + integrity sha512-kuip9YilBqhirhHEGHaBTZKXL//xxGnzvsD0FtBQa6z+A69qZD6s/BAX9VzDF1i9VKDquTJDQaPLSEhOnL6FvQ== dependencies: - browserslist "^4.5.4" - caniuse-lite "^1.0.30000957" + browserslist "^4.6.1" + caniuse-lite "^1.0.30000971" + chalk "^2.4.2" normalize-range "^0.1.2" num2fraction "^1.2.2" - postcss "^7.0.14" + postcss "^7.0.16" postcss-value-parser "^3.3.1" aws-sign2@~0.7.0: @@ -1990,6 +1991,15 @@ browserslist@^4.0.0, browserslist@^4.5.2, browserslist@^4.5.4: electron-to-chromium "^1.3.127" node-releases "^1.1.17" +browserslist@^4.6.1: + version "4.6.1" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.6.1.tgz#ee5059b1aec18cbec9d055d6cb5e24ae50343a9b" + integrity sha512-1MC18ooMPRG2UuVFJTHFIAkk6mpByJfxCrnUyvSlu/hyQSFHMrlhM02SzNuCV+quTP4CKmqtOMAIjrifrpBJXQ== + dependencies: + caniuse-lite "^1.0.30000971" + electron-to-chromium "^1.3.137" + node-releases "^1.1.21" + bser@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719" @@ -2231,11 +2241,16 @@ caniuse-api@^3.0.0: lodash.memoize "^4.1.2" lodash.uniq "^4.5.0" -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30000957, caniuse-lite@^1.0.30000963: +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30000963: version "1.0.30000963" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000963.tgz#5be481d5292f22aff5ee0db4a6c049b65b5798b1" integrity sha512-n4HUiullc7Lw0LyzpeLa2ffP8KxFBGdxqD/8G3bSL6oB758hZ2UE2CVK+tQN958tJIi0/tfpjAc67aAtoHgnrQ== +caniuse-lite@^1.0.30000971: + version "1.0.30000974" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000974.tgz#b7afe14ee004e97ce6dc73e3f878290a12928ad8" + integrity sha512-xc3rkNS/Zc3CmpMKuczWEdY2sZgx09BkAxfvkxlAEBTqcMHeL8QnPqhKse+5sRTi3nrw2pJwToD2WvKn1Uhvww== + capture-stack-trace@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz#a6c0bbe1f38f3aa0b92238ecb6ff42c344d4135d" @@ -2291,6 +2306,28 @@ charenc@~0.0.1: resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" integrity sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc= +cheerio@0.22.0: + version "0.22.0" + resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.22.0.tgz#a9baa860a3f9b595a6b81b1a86873121ed3a269e" + integrity sha1-qbqoYKP5tZWmuBsahocxIe06Jp4= + dependencies: + css-select "~1.2.0" + dom-serializer "~0.1.0" + entities "~1.1.1" + htmlparser2 "^3.9.1" + lodash.assignin "^4.0.9" + lodash.bind "^4.1.4" + lodash.defaults "^4.0.1" + lodash.filter "^4.4.0" + lodash.flatten "^4.2.0" + lodash.foreach "^4.3.0" + lodash.map "^4.4.0" + lodash.merge "^4.4.0" + lodash.pick "^4.2.1" + lodash.reduce "^4.4.0" + lodash.reject "^4.4.0" + lodash.some "^4.4.0" + cheerio@1.0.0-rc.3, cheerio@^1.0.0-rc.2: version "1.0.0-rc.3" resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.3.tgz#094636d425b2e9c0f4eb91a46c05630c9a1a8bf6" @@ -3467,7 +3504,7 @@ dom-helpers@^3.2.1: dependencies: "@babel/runtime" "^7.1.2" -dom-serializer@0, dom-serializer@~0.1.1: +dom-serializer@0, dom-serializer@~0.1.0, dom-serializer@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.1.tgz#1ec4059e284babed36eec2941d4a970a189ce7c0" integrity sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA== @@ -3605,6 +3642,11 @@ electron-to-chromium@^1.3.127, electron-to-chromium@^1.3.47: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.127.tgz#9b34d3d63ee0f3747967205b953b25fe7feb0e10" integrity sha512-1o25iFRf/dbgauTWalEzmD1EmRN3a2CzP/K7UVpYLEBduk96LF0FyUdCcf4Ry2mAWJ1VxyblFjC93q6qlLwA2A== +electron-to-chromium@^1.3.137: + version "1.3.148" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.148.tgz#5796c0d9eb0358d397163413b90bf376c5d8bf08" + integrity sha512-nuCOlXNlGMQmdzihIPGm2K3Yf3H1hke/1rK381i02pH8wNliJU9hVNnOi/xjmxt+mjABd/BzufP5nPHWKshLWA== + elliptic@^6.0.0: version "6.4.1" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.4.1.tgz#c2d0b7776911b86722c632c3c06c60f2f819939a" @@ -4736,10 +4778,10 @@ gatsby-awesome-pagination@0.3.4: dependencies: lodash "^4.17.10" -gatsby-cli@^2.6.4: - version "2.6.4" - resolved "https://registry.yarnpkg.com/gatsby-cli/-/gatsby-cli-2.6.4.tgz#9d8285e4b020425c88f5ed0986ff8b8124ad2849" - integrity sha512-0HLm88/bYxtfKgBeS+fIUgkYoa4odww6npCPB/ZWo18IcO1/XB0PPTqdGhgYm8juwdR68duOq7UNvIpBauB5hQ== +gatsby-cli@^2.6.5: + version "2.6.5" + resolved "https://registry.yarnpkg.com/gatsby-cli/-/gatsby-cli-2.6.5.tgz#54d812a7a9bfa39c48eaca1864d6bb56f4fde8c6" + integrity sha512-M0M6OoZ3ZVT6dYHP1I0scJBJzQlTbeElgO7C08acc68Qj9BD0LbSnt38kyJ60j1oceCndnGgNsLP6lg3iR87/A== dependencies: "@babel/code-frame" "^7.0.0" "@babel/runtime" "^7.0.0" @@ -4943,13 +4985,14 @@ gatsby-source-filesystem@2.0.38: valid-url "^1.0.9" xstate "^3.1.0" -gatsby-source-ghost@3.3.4: - version "3.3.4" - resolved "https://registry.yarnpkg.com/gatsby-source-ghost/-/gatsby-source-ghost-3.3.4.tgz#d56f8d27fb1ebf89b2f96c3e64f62039754ac25c" - integrity sha512-e/+roiYGDqPlC3JSRbNKDOHjI1RP9YcxdvGADvmVWS9WRkWHktvnUMK95rNSBPytrxDIQcWShn140PsnwUryAQ== +gatsby-source-ghost@3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/gatsby-source-ghost/-/gatsby-source-ghost-3.4.0.tgz#5e5ff5a477220ccbdc469d7b7cbf5c621db8d707" + integrity sha512-tZAAmV/tSX1hwRWTJX1qokomw1mU9cdHTEcK6VljYh7sanD7Nl0rErHHvkDduFi5I30uRRR9wLITASWHwztpyQ== dependencies: "@tryghost/content-api" "1.2.4" bluebird "3.5.5" + cheerio "0.22.0" gatsby-node-helpers "^0.3.0" qs "6.7.0" @@ -4987,10 +5030,10 @@ gatsby-transformer-sharp@2.1.21: semver "^5.6.0" sharp "^0.22.1" -gatsby@2.8.2: - version "2.8.2" - resolved "https://registry.yarnpkg.com/gatsby/-/gatsby-2.8.2.tgz#f76d21faf94dedfe8d6159c4cd1ba616fe9bc775" - integrity sha512-0JzVbcQEzojLN8lYwIGYByftYuiLVwb9g8+6jJY0ytxQnmi1YIxv43OWlHXoOknJiChFWc3BV6Q2cI1dTHPcqA== +gatsby@2.8.5: + version "2.8.5" + resolved "https://registry.yarnpkg.com/gatsby/-/gatsby-2.8.5.tgz#152ae131f8e8a9cd5c86e4eda3e908505861f3e5" + integrity sha512-R2uDNSUyFpLyPeU6Owm+hQX1uT3xdeQhhsK8arDGFPjILnkTOvEkbSqmNey+3yuFsiy7UyG8KZxiOlUjX0uZ0g== dependencies: "@babel/code-frame" "^7.0.0" "@babel/core" "^7.0.0" @@ -5004,7 +5047,7 @@ gatsby@2.8.2: "@reach/router" "^1.1.1" "@stefanprobst/lokijs" "^1.5.6-b" address "1.0.3" - autoprefixer "^9.4.3" + autoprefixer "^9.6.0" babel-core "7.0.0-bridge.0" babel-eslint "^9.0.0" babel-loader "^8.0.0" @@ -5048,7 +5091,7 @@ gatsby@2.8.2: flat "^4.0.0" fs-exists-cached "1.0.0" fs-extra "^5.0.0" - gatsby-cli "^2.6.4" + gatsby-cli "^2.6.5" gatsby-graphiql-explorer "^0.1.2" gatsby-link "^2.1.1" gatsby-plugin-page-creator "^2.0.13" @@ -6925,17 +6968,42 @@ lodash._reinterpolate@~3.0.0: resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0= +lodash.assignin@^4.0.9: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2" + integrity sha1-uo31+4QesKPoBEIysOJjqNxqKKI= + +lodash.bind@^4.1.4: + version "4.2.1" + resolved "https://registry.yarnpkg.com/lodash.bind/-/lodash.bind-4.2.1.tgz#7ae3017e939622ac31b7d7d7dcb1b34db1690d35" + integrity sha1-euMBfpOWIqwxt9fX3LGzTbFpDTU= + +lodash.defaults@^4.0.1: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" + integrity sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw= + lodash.every@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.every/-/lodash.every-4.6.0.tgz#eb89984bebc4364279bb3aefbbd1ca19bfa6c6a7" integrity sha1-64mYS+vENkJ5uzrvu9HKGb+mxqc= +lodash.filter@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace" + integrity sha1-ZosdSYFgOuHMWm+nYBQ+SAtMSs4= + +lodash.flatten@^4.2.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" + integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8= + lodash.flattendeep@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" integrity sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI= -lodash.foreach@^4.5.0: +lodash.foreach@^4.3.0, lodash.foreach@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" integrity sha1-Gmo16s5AEoDH8G3d7DUWWrJ+PlM= @@ -6945,7 +7013,7 @@ lodash.kebabcase@^4.1.1: resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36" integrity sha1-hImxyw0p/4gZXM7KRI/21swpXDY= -lodash.map@^4.6.0: +lodash.map@^4.4.0, lodash.map@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" integrity sha1-dx7Hg540c9nEzeKLGTlMNWL09tM= @@ -6960,11 +7028,31 @@ lodash.memoize@^4.1.2: resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= -lodash.merge@^4.6.0: +lodash.merge@^4.4.0, lodash.merge@^4.6.0: version "4.6.1" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54" integrity sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ== +lodash.pick@^4.2.1: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" + integrity sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM= + +lodash.reduce@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b" + integrity sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs= + +lodash.reject@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.reject/-/lodash.reject-4.6.0.tgz#80d6492dc1470864bbf583533b651f42a9f52415" + integrity sha1-gNZJLcFHCGS79YNTO2UfQqn1JBU= + +lodash.some@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d" + integrity sha1-G7nzFO9ri63tE7VJFpsqlF62jk0= + lodash.template@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.4.0.tgz#e73a0385c8355591746e020b99679c690e68fba0" @@ -7692,6 +7780,13 @@ node-releases@^1.1.17: dependencies: semver "^5.3.0" +node-releases@^1.1.21: + version "1.1.23" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.23.tgz#de7409f72de044a2fa59c097f436ba89c39997f0" + integrity sha512-uq1iL79YjfYC0WXoHbC/z28q/9pOl8kSHaXdWmAAc8No+bDwqkZbzIJz55g/MUsPgSGm9LZ7QSUbzTcH5tz47w== + dependencies: + semver "^5.3.0" + noms@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/noms/-/noms-0.0.0.tgz#da8ebd9f3af9d6760919b27d9cdc8092a7332859" @@ -8818,7 +8913,7 @@ postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.23: source-map "^0.6.1" supports-color "^5.4.0" -postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.5: +postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.5: version "7.0.14" resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.14.tgz#4527ed6b1ca0d82c53ce5ec1a2041c2346bbd6e5" integrity sha512-NsbD6XUUMZvBxtQAJuWDJeeC4QFsmWsfozWxCJPWf3M55K9iu2iMDaKqyoOdTJ1R4usBXuxlVFAIo8rZPQD4Bg== @@ -8827,6 +8922,15 @@ postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.5: source-map "^0.6.1" supports-color "^6.1.0" +postcss@^7.0.16: + version "7.0.17" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.17.tgz#4da1bdff5322d4a0acaab4d87f3e782436bad31f" + integrity sha512-546ZowA+KZ3OasvQZHsbuEpysvwTZNGJv9EfyCQdsIDltPSWHAeTQ5fQy/Npi2ZDtLI3zs7Ps/p6wThErhm9fQ== + dependencies: + chalk "^2.4.2" + source-map "^0.6.1" + supports-color "^6.1.0" + potrace@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/potrace/-/potrace-2.1.1.tgz#79111a858197f366418845f667fe8f7fac0a79db"