Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit 4be239c

Browse files
committed
Sync with changes from TryGhost/gatsby-starter-ghost
1 parent 7afdde8 commit 4be239c

File tree

7 files changed

+1121
-1728
lines changed

7 files changed

+1121
-1728
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ typings/
5858

5959
# dotenv environment variables file
6060
.env
61+
.env.development
62+
.env.production
6163

6264
# IDE
6365
.idea/*

gatsby-node.js

+28-68
Original file line numberDiff line numberDiff line change
@@ -68,86 +68,46 @@ exports.createPages = async ({ graphql, actions }) => {
6868
// Create tag pages
6969
tags.forEach(({ node }) => {
7070
const totalPosts = node.postCount !== null ? node.postCount : 0
71-
const numberOfPages = Math.ceil(totalPosts / postsPerPage)
7271

7372
// This part here defines, that our tag pages will use
7473
// a `/tag/:slug/` permalink.
75-
node.url = `/tag/${node.slug}/`
76-
77-
Array.from({ length: numberOfPages }).forEach((_, i) => {
78-
const currentPage = i + 1
79-
const prevPageNumber = currentPage <= 1 ? null : currentPage - 1
80-
const nextPageNumber =
81-
currentPage + 1 > numberOfPages ? null : currentPage + 1
82-
const previousPagePath = prevPageNumber
83-
? prevPageNumber === 1
84-
? node.url
85-
: `${node.url}page/${prevPageNumber}/`
86-
: null
87-
const nextPagePath = nextPageNumber
88-
? `${node.url}page/${nextPageNumber}/`
89-
: null
90-
91-
createPage({
92-
path: i === 0 ? node.url : `${node.url}page/${i + 1}/`,
93-
component: tagsTemplate,
94-
context: {
95-
// Data passed to context is available
96-
// in page queries as GraphQL variables.
97-
slug: node.slug,
98-
limit: postsPerPage,
99-
skip: i * postsPerPage,
100-
numberOfPages: numberOfPages,
101-
humanPageNumber: currentPage,
102-
prevPageNumber: prevPageNumber,
103-
nextPageNumber: nextPageNumber,
104-
previousPagePath: previousPagePath,
105-
nextPagePath: nextPagePath,
106-
},
107-
})
74+
const url = `/tag/${node.slug}`
75+
76+
const items = Array.from({length: totalPosts})
77+
78+
// Create pagination
79+
paginate({
80+
createPage,
81+
items: items,
82+
itemsPerPage: postsPerPage,
83+
component: tagsTemplate,
84+
pathPrefix: ({ pageNumber }) => (pageNumber === 0) ? url : `${url}/page`,
85+
context: {
86+
slug: node.slug
87+
}
10888
})
10989
})
11090

11191
// Create author pages
11292
authors.forEach(({ node }) => {
11393
const totalPosts = node.postCount !== null ? node.postCount : 0
114-
const numberOfPages = Math.ceil(totalPosts / postsPerPage)
11594

11695
// This part here defines, that our author pages will use
11796
// a `/author/:slug/` permalink.
118-
node.url = `/author/${node.slug}/`
119-
120-
Array.from({ length: numberOfPages }).forEach((_, i) => {
121-
const currentPage = i + 1
122-
const prevPageNumber = currentPage <= 1 ? null : currentPage - 1
123-
const nextPageNumber =
124-
currentPage + 1 > numberOfPages ? null : currentPage + 1
125-
const previousPagePath = prevPageNumber
126-
? prevPageNumber === 1
127-
? node.url
128-
: `${node.url}page/${prevPageNumber}/`
129-
: null
130-
const nextPagePath = nextPageNumber
131-
? `${node.url}page/${nextPageNumber}/`
132-
: null
133-
134-
createPage({
135-
path: i === 0 ? node.url : `${node.url}page/${i + 1}/`,
136-
component: authorTemplate,
137-
context: {
138-
// Data passed to context is available
139-
// in page queries as GraphQL variables.
140-
slug: node.slug,
141-
limit: postsPerPage,
142-
skip: i * postsPerPage,
143-
numberOfPages: numberOfPages,
144-
humanPageNumber: currentPage,
145-
prevPageNumber: prevPageNumber,
146-
nextPageNumber: nextPageNumber,
147-
previousPagePath: previousPagePath,
148-
nextPagePath: nextPagePath,
149-
},
150-
})
97+
const url = `/author/${node.slug}`
98+
99+
const items = Array.from({length: totalPosts})
100+
101+
// Create pagination
102+
paginate({
103+
createPage,
104+
items: items,
105+
itemsPerPage: postsPerPage,
106+
component: authorTemplate,
107+
pathPrefix: ({ pageNumber }) => (pageNumber === 0) ? url : `${url}/page`,
108+
context: {
109+
slug: node.slug
110+
}
151111
})
152112
})
153113

plugins/gatsby-plugin-ghost-manifest/gatsby-node.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ function generateIcons(icons, srcIcon) {
3333
}
3434

3535
exports.onPostBuild = /*#__PURE__*/function () {
36-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref2, pluginOptions) {
37-
var graphql, icon, manifest, _ref3, data, siteTitle, iconPath;
36+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref, pluginOptions) {
37+
var graphql, icon, manifest, _yield$graphql, data, siteTitle, iconPath;
3838

3939
return _regenerator.default.wrap(function _callee$(_context) {
4040
while (1) {
4141
switch (_context.prev = _context.next) {
4242
case 0:
43-
graphql = _ref2.graphql;
43+
graphql = _ref.graphql;
4444
icon = pluginOptions.icon, manifest = (0, _objectWithoutPropertiesLoose2.default)(pluginOptions, ["icon"]);
4545
_context.next = 4;
4646
return graphql(pluginOptions.query);
4747

4848
case 4:
49-
_ref3 = _context.sent;
50-
data = _ref3.data;
49+
_yield$graphql = _context.sent;
50+
data = _yield$graphql.data;
5151
siteTitle = data.allGhostSettings.edges[0].node.title || "No Title";
5252
manifest = (0, _extends2.default)({}, manifest, {
5353
name: siteTitle
@@ -95,6 +95,6 @@ exports.onPostBuild = /*#__PURE__*/function () {
9595
}));
9696

9797
return function (_x, _x2) {
98-
return _ref.apply(this, arguments);
98+
return _ref2.apply(this, arguments);
9999
};
100-
}();
100+
}();

plugins/gatsby-plugin-ghost-manifest/gatsby-ssr.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exports.onRenderBody = function (_ref, pluginOptions) {
1818
var favicon = icons && icons.length ? icons[0].src : null;
1919

2020
if (favicon) {
21-
headComponents.push(_react.default.createElement("link", {
21+
headComponents.push( /*#__PURE__*/_react.default.createElement("link", {
2222
key: "gatsby-plugin-manifest-icon-link",
2323
rel: "shortcut icon",
2424
href: (0, _gatsby.withPrefix)(favicon)
@@ -27,7 +27,7 @@ exports.onRenderBody = function (_ref, pluginOptions) {
2727
} // Add manifest link tag.
2828

2929

30-
headComponents.push(_react.default.createElement("link", {
30+
headComponents.push( /*#__PURE__*/_react.default.createElement("link", {
3131
key: "gatsby-plugin-manifest-link",
3232
rel: "manifest",
3333
href: (0, _gatsby.withPrefix)("/manifest.webmanifest")
@@ -37,7 +37,7 @@ exports.onRenderBody = function (_ref, pluginOptions) {
3737
var insertMetaTag = Object.keys(pluginOptions).includes("theme_color_in_head") ? pluginOptions.theme_color_in_head : true;
3838

3939
if (insertMetaTag) {
40-
headComponents.push(_react.default.createElement("meta", {
40+
headComponents.push( /*#__PURE__*/_react.default.createElement("meta", {
4141
key: "gatsby-plugin-manifest-meta",
4242
name: "theme-color",
4343
content: pluginOptions.theme_color
@@ -47,7 +47,7 @@ exports.onRenderBody = function (_ref, pluginOptions) {
4747

4848
if (pluginOptions.legacy) {
4949
var iconLinkTags = icons.map(function (icon) {
50-
return _react.default.createElement("link", {
50+
return /*#__PURE__*/_react.default.createElement("link", {
5151
key: "gatsby-plugin-manifest-apple-touch-icon-" + icon.sizes,
5252
rel: "apple-touch-icon",
5353
sizes: icon.sizes,
@@ -58,4 +58,4 @@ exports.onRenderBody = function (_ref, pluginOptions) {
5858
}
5959

6060
setHeadComponents(headComponents);
61-
};
61+
};

plugins/gatsby-plugin-ghost-manifest/package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"version": "0.0.1",
55
"author": "Ghost Foundation",
66
"dependencies": {
7-
"@babel/runtime": "7.10.4",
7+
"@babel/runtime": "7.12.5",
88
"bluebird": "3.7.2",
9-
"sharp": "0.25.4"
9+
"sharp": "0.27.0"
1010
},
1111
"devDependencies": {
12-
"@babel/cli": "7.10.4",
13-
"@babel/core": "7.10.4",
14-
"babel-preset-gatsby-package": "0.5.1",
15-
"cross-env": "7.0.2"
12+
"@babel/cli": "7.12.10",
13+
"@babel/core": "7.12.10",
14+
"babel-preset-gatsby-package": "0.11.0",
15+
"cross-env": "7.0.3"
1616
},
1717
"keywords": [
1818
"gatsby",
@@ -24,7 +24,7 @@
2424
"pwa"
2525
],
2626
"resolutions": {
27-
"sharp": "0.25.4"
27+
"sharp": "0.27.0"
2828
},
2929
"license": "MIT",
3030
"main": "index.js",

0 commit comments

Comments
 (0)