Skip to content

Commit 28e34aa

Browse files
authored
Move case studies to Contentful (#39)
* Install gatsby contentful plugin * Configure Contentful in gatsby config * Add contentful secrets for build publish workflow * Remove unused gatsby plugins and update node version * Delete articles unused components * Update gatsby and react * Generate URLs of case studies using Contentful * Fetch case study list from Contentful * Remove defaultProps * Remove duplicate CSS in case study template * Query case study from contentful * Display takeaways from Ghost * Style quick takeaways section * Remove prop-types from navigation * Update gatsby plugin sharp * Rename images to remove blankspaces * Remove unused blog hero * Remove unused ghost icon * Replace cta bg query with static import of cta image * Remove StaticQuery * Install dependencies * Set object fit to cover
1 parent d0d582d commit 28e34aa

23 files changed

+4903
-8459
lines changed

.github/workflows/build_publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ jobs:
2424
SITEPATH: ""
2525
GHOST_API_URL: ${{ secrets.GHOST_API_URL }}
2626
GHOST_CONTENT_API_KEY: ${{ secrets.GHOST_CONTENT_API_KEY }}
27+
CONTENTFUL_ACCESS_TOKEN: ${{ secrets.CONTENTFUL_ACCESS_TOKEN }}
28+
CONTENTFUL_SPACE_ID: ${{ secrets.CONTENTFUL_SPACE_ID }}

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20.11.1
1+
v20.18.1

gatsby-config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ module.exports = {
4444
resolve: `gatsby-source-ghost`,
4545
options: ghostConfig.production,
4646
},
47+
{
48+
resolve: `gatsby-source-contentful`,
49+
options: {
50+
spaceId: process.env.CONTENTFUL_SPACE_ID,
51+
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
52+
},
53+
},
4754
{
4855
resolve: `gatsby-plugin-google-gtag`,
4956
options: {

gatsby-node.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const path = require(`path`);
2-
const { postsPerPage } = require(`./src/utils/siteConfig`);
3-
const { paginate } = require(`gatsby-awesome-pagination`);
42
const util = require("util");
53
const glob = require("glob");
64
const fs = require("fs");
@@ -38,32 +36,32 @@ exports.onPostBuild = async () => {
3836

3937
/**
4038
* Here is the place where Gatsby creates the URLs for all the
41-
* posts, tags, pages and authors that we fetched from the Ghost site.
39+
* posts, tags, pages and authors that we fetched from the Contentful.
4240
*/
4341

4442
exports.createPages = async ({ actions, graphql }) => {
4543
const { createPage } = actions;
4644

4745
const result = await graphql(`
4846
{
49-
allGhostPost(
50-
filter: {
51-
tags: { elemMatch: { slug: { eq: "hash-community-case-study" } } }
52-
}
53-
) {
54-
nodes {
55-
slug
47+
caseStudies: allContentfulCaseStudy(sort: { datePublished: DESC }) {
48+
edges {
49+
node {
50+
url
51+
}
5652
}
5753
}
5854
}
5955
`);
6056

61-
result.data.allGhostPost.nodes.forEach((post) => {
57+
const caseStudies = result.data.caseStudies.edges;
58+
59+
caseStudies.forEach(({ node }) => {
6260
createPage({
63-
path: `/community-case-studies/${post.slug}/`,
61+
path: `/community-case-studies/${node.url}/`,
6462
component: require.resolve(`./src/templates/CaseStudy.js`),
6563
context: {
66-
slug: post.slug,
64+
url: node.url,
6765
},
6866
});
6967
});

package.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"gatsby-plugin-sharp/probe-image-size": "^7.0.0"
1515
},
1616
"engines": {
17-
"node": ">= 20.11.1"
17+
"node": ">= 20.18.1"
1818
},
1919
"bugs": {
2020
"url": "https://github.com/tryghost/gatsby-starter-ghost/issues"
@@ -48,10 +48,7 @@
4848
"autoprefixer": "^10.2.5",
4949
"cheerio": "1.0.0-rc.5",
5050
"dotenv": "^8.2.0",
51-
"gatsby": "^3.1.2",
52-
"gatsby-awesome-pagination": "0.3.6",
53-
"gatsby-image": "^3.2.0",
54-
"gatsby-plugin-advanced-sitemap": "1.6.0",
51+
"gatsby": "^5.0.0",
5552
"gatsby-plugin-anchor-links": "^1.2.1",
5653
"gatsby-plugin-catch-links": "2.10.0",
5754
"gatsby-plugin-force-trailing-slashes": "1.0.5",
@@ -65,19 +62,20 @@
6562
"gatsby-plugin-react-svg": "^3.0.1",
6663
"gatsby-plugin-sass": "^5.0.0",
6764
"gatsby-plugin-scroll-reveal": "^0.0.7",
68-
"gatsby-plugin-sharp": "2.14.3",
65+
"gatsby-plugin-sharp": "^5.8.1",
6966
"gatsby-remark-prismjs": "^5.2.0",
67+
"gatsby-source-contentful": "^8.13.2",
7068
"gatsby-source-filesystem": "2.11.1",
7169
"gatsby-source-ghost": "^5.0.3",
72-
"gatsby-transformer-remark": "^4.2.0",
73-
"gatsby-transformer-sharp": "2.12.1",
70+
"gatsby-transformer-remark": "^6.11.0",
71+
"gatsby-transformer-sharp": "^5.8.0",
7472
"hamburger-react": "^2.4.0",
7573
"lodash": "4.17.21",
7674
"md5": "^2.3.0",
7775
"postcss": "^8.2.10",
7876
"prismjs": "^1.23.0",
79-
"react": "17.0.1",
80-
"react-dom": "17.0.1",
77+
"react": "^18.0.1",
78+
"react-dom": "^18.0.1",
8179
"react-helmet": "6.1.0",
8280
"recharts": "^2.15.3",
8381
"sass": "^1.32.10",

src/components/AllArticlesWrap.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/components/FeaturedArticle.js

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/components/FeaturedArticleWrap.js

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)