Skip to content

Commit 8332c63

Browse files
committed
reverted previous commit and other minor bug fixes and improvements and version bump
1 parent 9db4cfa commit 8332c63

File tree

7 files changed

+113
-61
lines changed

7 files changed

+113
-61
lines changed

example/.env.development

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
FORM_URL=http://localhost:3000/api/project/5e81b8923d8c2d64d8549add/forms
2-
DISQUS_SHORTNAME=
2+
GATSBY_DISQUS_SHORTNAME=
33
GATSBY_FB_APP_ID=

example/src/@draftbox-co/gatsby-theme-ghost-attila/components/disqus.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { DiscussionEmbed } from "disqus-react";
33

44
const Disqus = props => {
55
const disqusConfig = {
6-
shortname: process.env.DISQUS_SHORTNAME,
6+
shortname: process.env.GATSBY_DISQUS_SHORTNAME,
77
identifier: props.slug,
88
title: props.slug
99
};
10-
return process.env.DISQUS_SHORTNAME ? (
10+
return process.env.GATSBY_DISQUS_SHORTNAME ? (
1111
<DiscussionEmbed {...disqusConfig} />
1212
) : (
1313
<></>

gatsby-theme-ghost-attila/gatsby-config.js

+36-34
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,37 @@ const ghostConfigDefaults = require(`./src/utils/.ghost.json`);
55

66
const generateRSSFeed = require(`./src/utils/rss/generate-feed`);
77

8-
module.exports = themeOptions => {
8+
module.exports = (themeOptions) => {
99
const siteConfig = themeOptions.siteConfig || siteConfigDefaults;
1010
const ghostConfig = themeOptions.ghostConfig || ghostConfigDefaults;
11-
const finalConfig = process.env.NODE_ENV === `development`
12-
? ghostConfig.development
13-
: ghostConfig.production;
11+
const finalConfig =
12+
process.env.NODE_ENV === `development`
13+
? ghostConfig.development
14+
: ghostConfig.production;
1415

1516
siteConfig.apiUrl = finalConfig.apiUrl;
16-
console.log('what is', siteConfig);
17+
console.log("what is", siteConfig);
1718
return {
1819
siteMetadata: siteConfig,
1920
plugins: [
2021
{
2122
resolve: `gatsby-plugin-sass`,
2223
options: {
23-
sassRuleModulesTest: /.*\.module\.s(a|c)ss$/
24-
}
24+
sassRuleModulesTest: /.*\.module\.s(a|c)ss$/,
25+
},
2526
},
2627
{
2728
resolve: `gatsby-plugin-page-creator`,
2829
options: {
29-
path: path.join(__dirname, `src`, `pages`)
30-
}
30+
path: path.join(__dirname, `src`, `pages`),
31+
},
3132
},
3233
{
3334
resolve: `gatsby-source-filesystem`,
3435
options: {
3536
path: path.join(__dirname, `src`, `images`),
36-
name: `images`
37-
}
37+
name: `images`,
38+
},
3839
},
3940
`gatsby-plugin-sharp`,
4041
`gatsby-transformer-sharp`,
@@ -43,23 +44,23 @@ module.exports = themeOptions => {
4344
options:
4445
process.env.NODE_ENV === `development`
4546
? ghostConfig.development
46-
: ghostConfig.production
47+
: ghostConfig.production,
4748
},
4849
{
4950
resolve: `gatsby-transformer-rehype`,
5051
options: {
51-
filter: node =>
52+
filter: (node) =>
5253
node.internal.type === `GhostPost` ||
5354
node.internal.type === `GhostPage`,
5455
plugins: [
5556
{
56-
resolve: `gatsby-rehype-prismjs`
57+
resolve: `gatsby-rehype-prismjs`,
5758
},
5859
{
59-
resolve: `gatsby-rehype-ghost-links`
60-
}
61-
]
62-
}
60+
resolve: `gatsby-rehype-ghost-links`,
61+
},
62+
],
63+
},
6364
},
6465
/**
6566
* Utility Plugins
@@ -81,8 +82,8 @@ module.exports = themeOptions => {
8182
siteDescription
8283
}
8384
}
84-
}`
85-
}
85+
}`,
86+
},
8687
},
8788
{
8889
resolve: `gatsby-plugin-feed`,
@@ -97,8 +98,8 @@ module.exports = themeOptions => {
9798
}
9899
}
99100
}`,
100-
feeds: [generateRSSFeed(siteConfig)]
101-
}
101+
feeds: [generateRSSFeed(siteConfig)],
102+
},
102103
},
103104
{
104105
resolve: `gatsby-plugin-advanced-sitemap`,
@@ -148,17 +149,17 @@ module.exports = themeOptions => {
148149
`,
149150
mapping: {
150151
allGhostPost: {
151-
sitemap: `posts`
152+
sitemap: `posts`,
152153
},
153154
allGhostTag: {
154-
sitemap: `tags`
155+
sitemap: `tags`,
155156
},
156157
allGhostAuthor: {
157-
sitemap: `authors`
158+
sitemap: `authors`,
158159
},
159160
allGhostPage: {
160-
sitemap: `pages`
161-
}
161+
sitemap: `pages`,
162+
},
162163
},
163164
exclude: [
164165
`/dev-404-page`,
@@ -169,17 +170,17 @@ module.exports = themeOptions => {
169170
`/offline.html`,
170171
],
171172
createLinkInHead: true,
172-
addUncaughtPages: true
173-
}
173+
addUncaughtPages: true,
174+
},
174175
},
175176
`gatsby-plugin-catch-links`,
176177
`gatsby-plugin-react-helmet`,
177178
`gatsby-plugin-force-trailing-slashes`,
178179
{
179180
resolve: `gatsby-plugin-postcss`,
180181
options: {
181-
postCssPlugins: [require(`cssnano`)()]
182-
}
182+
postCssPlugins: [require(`cssnano`)()],
183+
},
183184
},
184185
{
185186
resolve: `@draftbox-co/gatsby-plugin-amp`,
@@ -191,15 +192,16 @@ module.exports = themeOptions => {
191192
relAmpHtmlPattern: `{{canonicalBaseUrl}}{{pathname}}{{pathIdentifier}}`,
192193
useAmpClientIdApi: true,
193194
dirName: __dirname,
194-
themePath: `src/amp-styles/post.amp.css`
195-
}
195+
themePath: `src/amp-styles/post.amp.css`,
196+
},
196197
},
197198
{
198199
resolve: `gatsby-plugin-remove-generator`,
199200
options: {
200201
content: `Draftbox`,
201202
},
202203
},
203-
]
204+
`gatsby-plugin-remove-serviceworker`,
205+
],
204206
};
205207
};

gatsby-theme-ghost-attila/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@draftbox-co/gatsby-theme-ghost-attila",
33
"description": "A Gatsby theme plugin for creating blogs from headless Ghost CMS.",
4-
"version": "1.0.40",
4+
"version": "1.0.42",
55
"license": "MIT",
66
"author": "Draftbox",
77
"homepage": "https://github.com/draftbox-co/gatsby-attila-theme-ghost",
@@ -69,11 +69,11 @@
6969
"gatsby-plugin-feed": "^2.3.27",
7070
"gatsby-plugin-force-trailing-slashes": "^1.0.4",
7171
"gatsby-plugin-manifest": "^2.2.42",
72-
"gatsby-plugin-remove-serviceworker": "^1.0.0",
7372
"gatsby-plugin-page-creator": "^2.1.40",
7473
"gatsby-plugin-postcss": "^2.1.20",
7574
"gatsby-plugin-react-helmet": "^3.1.22",
7675
"gatsby-plugin-remove-generator": "^1.0.5",
76+
"gatsby-plugin-remove-serviceworker": "^1.0.0",
7777
"gatsby-plugin-sass": "^2.1.29",
7878
"gatsby-plugin-sharp": "^2.4.5",
7979
"gatsby-rehype-ghost-links": "^1.1.0",
@@ -86,6 +86,7 @@
8686
"node-sass": "^4.13.1",
8787
"prismjs": "^1.19.0",
8888
"react-helmet": "^5.2.1",
89+
"react-intersection-observer": "^8.26.2",
8990
"reading-time": "^1.2.0",
9091
"styled-components": "^5.0.1"
9192
}

gatsby-theme-ghost-attila/src/components/post-card.jsx

+15-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ const PostCard = ({ post }) => {
1212
<div id={post.uuid} className="container">
1313
<main className="content" role="main">
1414
<div>
15-
<article className={`post tag-getting-started ${post.featured ? 'featured' : ''}`}>
15+
<article
16+
className={`post tag-getting-started ${
17+
post.featured ? "featured" : ""
18+
}`}
19+
>
1620
<div className="inner">
1721
<div className="box post-box">
1822
<h2 className="post-title">
@@ -26,16 +30,16 @@ const PostCard = ({ post }) => {
2630
<span className="post-meta">
2731
By{" "}
2832
{post.authors.map((author, index) => (
29-
<>
30-
<Link
31-
key={index}
32-
className="post-meta-tag"
33-
to={`/author/${author.slug}`}
34-
>
35-
{author.name}
36-
</Link>
37-
{index !== post.authors.length - 1 ? ", " : ""}
38-
</>
33+
<React.Fragment key={index}>
34+
<Link
35+
key={index}
36+
className="post-meta-tag"
37+
to={`/author/${author.slug}`}
38+
>
39+
{author.name}
40+
</Link>
41+
{index !== post.authors.length - 1 ? ", " : ""}
42+
</React.Fragment>
3943
))}
4044
{post.tags.length > 0 && " in "}
4145
{post.tags.map((tag, index) => (

gatsby-theme-ghost-attila/src/templates/postTemplate.jsx

+38-10
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,19 @@ import Disqus from "../components/disqus";
99
import FbComments from "../components/fb-comments";
1010
import CopyLink from "../components/copy-link";
1111
import "../styles/prism-theme/prism_dracula.scss";
12+
import { InView } from "react-intersection-observer";
1213

1314
const PostTemplate = ({ data, location, pageContext }) => {
1415
const [href, sethref] = useState("");
1516

17+
const [showComments, setshowComments] = useState(false);
18+
19+
const handleCommentsVisibility = (inView) => {
20+
if (inView && !showComments) {
21+
setshowComments(true);
22+
}
23+
};
24+
1625
useEffect(() => {
1726
if (typeof window !== "undefined") {
1827
sethref(window.location.href);
@@ -58,7 +67,7 @@ const PostTemplate = ({ data, location, pageContext }) => {
5867
window.removeEventListener("scroll", readingProgessTracker);
5968
}
6069
};
61-
});
70+
}, []);
6271

6372
return (
6473
<>
@@ -255,15 +264,34 @@ const PostTemplate = ({ data, location, pageContext }) => {
255264
</aside>
256265
</div>
257266
</article>
258-
<div className="inner embed-ghost" style={{ marginTop: "20px" }}>
259-
<Disqus slug={pageContext.slug} title={data.ghostPost.title} />
260-
</div>
261-
<div className="inner embed-facebook" style={{ marginTop: "20px" }}>
262-
<FbComments
263-
slug={pageContext.slug}
264-
title={data.ghostPost.title}
265-
href={href}
266-
/>
267+
<InView
268+
as="div"
269+
onChange={(inView) => handleCommentsVisibility(inView)}
270+
></InView>
271+
<div>
272+
{process.env.GATSBY_DISQUS_SHORTNAME && showComments && (
273+
<div
274+
className="inner embed-ghost"
275+
style={{ marginTop: "20px" }}
276+
>
277+
<Disqus
278+
slug={pageContext.slug}
279+
title={data.ghostPost.title}
280+
/>
281+
</div>
282+
)}
283+
{process.env.GATSBY_FB_APP_ID && showComments && (
284+
<div
285+
className="inner embed-facebook"
286+
style={{ marginTop: "20px" }}
287+
>
288+
<FbComments
289+
slug={pageContext.slug}
290+
title={data.ghostPost.title}
291+
href={href}
292+
/>
293+
</div>
294+
)}
267295
</div>
268296
</main>
269297
<SubscribeForm />

yarn.lock

+18-1
Original file line numberDiff line numberDiff line change
@@ -1937,6 +1937,11 @@
19371937
version "2.30.0"
19381938
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.30.0.tgz#7681c305a6f4341ae2579f5e3a75846c29eee9ce"
19391939
integrity sha512-9kDOxzp0K85UnpmPJqUzdWaCNorYYgk1yZmf4IKzpeTlSAclnFsrLjfwD9mQExctLoLoGAUXq1co+fbr+3HeFw==
1940+
dependencies:
1941+
"@types/eslint-visitor-keys" "^1.0.0"
1942+
"@typescript-eslint/experimental-utils" "2.30.0"
1943+
"@typescript-eslint/typescript-estree" "2.30.0"
1944+
eslint-visitor-keys "^1.1.0"
19401945

19411946
"@typescript-eslint/[email protected]":
19421947
version "2.30.0"
@@ -11923,6 +11928,13 @@ react-hot-loader@^4.12.20:
1192311928
shallowequal "^1.1.0"
1192411929
source-map "^0.7.3"
1192511930

11931+
react-intersection-observer@^8.26.2:
11932+
version "8.26.2"
11933+
resolved "https://registry.yarnpkg.com/react-intersection-observer/-/react-intersection-observer-8.26.2.tgz#0562ff0c06b2b10e809190c2fa9b6ded656e6e16"
11934+
integrity sha512-GmSjLNK+oV7kS+BHfrJSaA4wF61ELA33gizKHmN+tk59UT6/aW8kkqvlrFGPwxGoaIzLKS2evfG5fgkw5MIIsg==
11935+
dependencies:
11936+
tiny-invariant "^1.1.0"
11937+
1192611938
react-is@^16.12.0:
1192711939
version "16.13.1"
1192811940
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
@@ -12918,7 +12930,7 @@ shallowequal@^1.0.1, shallowequal@^1.1.0:
1291812930
resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8"
1291912931
integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==
1292012932

12921-
sharp@^0.23.4:
12933+
sharp@0.23.4, sharp@^0.23.4:
1292212934
version "0.23.4"
1292312935
resolved "https://registry.yarnpkg.com/sharp/-/sharp-0.23.4.tgz#ca36067cb6ff7067fa6c77b01651cb9a890f8eb3"
1292412936
integrity sha512-fJMagt6cT0UDy9XCsgyLi0eiwWWhQRxbwGmqQT6sY8Av4s0SVsT/deg8fobBQCTDU5iXRgz0rAeXoE2LBZ8g+Q==
@@ -13991,6 +14003,11 @@ tiny-emitter@^2.0.0:
1399114003
resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz#1d1a56edfc51c43e863cbb5382a72330e3555423"
1399214004
integrity sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==
1399314005

14006+
tiny-invariant@^1.1.0:
14007+
version "1.1.0"
14008+
resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.1.0.tgz#634c5f8efdc27714b7f386c35e6760991d230875"
14009+
integrity sha512-ytxQvrb1cPc9WBEI/HSeYYoGD0kWnGEOR8RY6KomWLBVhqz0RgTwVO9dLrGz7dC+nN9llyI7OKAgRq8Vq4ZBSw==
14010+
1399414011
tinycolor2@^1.4.1:
1399514012
version "1.4.1"
1399614013
resolved "https://registry.yarnpkg.com/tinycolor2/-/tinycolor2-1.4.1.tgz#f4fad333447bc0b07d4dc8e9209d8f39a8ac77e8"

0 commit comments

Comments
 (0)