Skip to content

Commit 0c67f31

Browse files
committed
Fix for wrong cover url on pagination
1 parent 8f43c58 commit 0c67f31

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

gatsby-wordpress-theme-libre/gatsby-node.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
258258
subscribeWidget {
259259
visible
260260
}
261+
coverUrl
262+
siteUrl
261263
}
262264
}
263265
@@ -280,6 +282,8 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
280282
const pages = result.data.allWordpressPage.edges;
281283
const siteTitle = result.data.site.siteMetadata.siteTitle;
282284
const subscribeWidget = result.data.site.siteMetadata.subscribeWidget;
285+
const siteUrl = result.data.site.siteMetadata.siteUrl;
286+
const coverUrl = result.data.site.siteMetadata.coverUrl;
283287

284288
posts.forEach((post, i, arr) => {
285289
createPage({
@@ -342,6 +346,10 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
342346
items: posts,
343347
itemsPerPage: postsPerPage,
344348
component: indexTemplate,
349+
context: {
350+
coverUrl: coverUrl,
351+
siteUrl: siteUrl
352+
},
345353
pathPrefix: ({ pageNumber }) => {
346354
if (pageNumber === 0) {
347355
return `/`;

gatsby-wordpress-theme-libre/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@draftbox-co/gatsby-wordpress-theme-libre",
3-
"version": "1.0.44",
3+
"version": "1.0.45",
44
"license": "MIT",
55
"resolutions": {
66
"sharp": "0.23.4"

gatsby-wordpress-theme-libre/src/templates/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,24 @@ import Pagination from "../components/pagination";
66
import Footer from "../components/footer";
77
import WebsiteMeta from "../components/meta/website-meta";
88
import { Link } from "gatsby";
9+
import url from "url";
910

1011
const Index = ({ data, pageContext }) => {
12+
const {coverUrl, siteUrl} = pageContext
1113
return (
1214
<>
1315
<Layout>
1416
<WebsiteMeta />
1517
<div className="home blog wp-embed-responsive">
1618
<div id="page" className="hfeed site">
17-
{data.site.siteMetadata.coverUrl && (
19+
{coverUrl && (
1820
<div
1921
className="custom-header-container"
2022
style={{ height: "200px" }}
2123
>
2224
<Link to="/" rel="home">
2325
<img
24-
src={data.site.siteMetadata.coverUrl}
26+
src={url.resolve(siteUrl,coverUrl)}
2527
alt=""
2628
className="custom-header"
2729
/>
@@ -62,11 +64,5 @@ export const pageQuery = graphql`
6264
}
6365
}
6466
}
65-
66-
site {
67-
siteMetadata {
68-
coverUrl
69-
}
70-
}
7167
}
7268
`;

0 commit comments

Comments
 (0)