Skip to content

Commit a79bccf

Browse files
committed
changed post slugs to permalink slugs and improvements in amp pages and updated readme file and version update
1 parent 444f72a commit a79bccf

File tree

9 files changed

+162
-34
lines changed

9 files changed

+162
-34
lines changed

example/site-config.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
siteUrl: "https://wp-balsa-preview.draftbox.co", // Site domain. Do not include a trailing slash!
2+
siteUrl: "https://wp-libre-preview.draftbox.co", // Site domain. Do not include a trailing slash!
33

44
postsPerPage: 10, // Number of posts shown on paginated pages (changes this requires sometimes to delete the cache)
55

@@ -14,7 +14,7 @@ module.exports = {
1414
siteIcon: "favicon.png", // Logo in /static dir used for SEO, RSS, and App manifest
1515
backgroundColor: "#e9e9e9", // Used for Offline Manifest
1616
themeColor: "#15171A", // Used for Offline Manifest
17-
apiUrl: "https://wordpress.theasdfghjkl.com",
17+
apiUrl: "https://wordpress.theasdfghjkl.com",
1818
subscribeWidget: {
1919
title: "Subscribe to Draftbox",
2020
helpText: "Get the latest posts delivered right to your inbox.",
@@ -24,11 +24,11 @@ module.exports = {
2424
navigation: [
2525
{
2626
label: "Home",
27-
url: "https://wp-balsa-preview.draftbox.co/",
27+
url: "https://wp-libre-preview.draftbox.co/",
2828
},
2929
{
3030
label: "Contact",
31-
url: "https://wp-balsa-preview.draftbox.co/contact",
31+
url: "https://wp-libre-preview.draftbox.co/contact",
3232
},
3333
],
3434
},
@@ -37,19 +37,19 @@ module.exports = {
3737
navigation: [
3838
{
3939
label: "Home",
40-
url: "https://wp-balsa-preview.draftbox.co/",
40+
url: "https://wp-libre-preview.draftbox.co/",
4141
},
4242
{
4343
label: "Sitemap",
44-
url: "https://wp-balsa-preview.draftbox.co/sitemap.xml",
44+
url: "https://wp-libre-preview.draftbox.co/sitemap.xml",
4545
},
4646
{
4747
label: "RSS",
48-
url: "https://wp-balsa-preview.draftbox.co/rss.xml",
48+
url: "https://wp-libre-preview.draftbox.co/rss.xml",
4949
},
5050
{
5151
label: "Contact",
52-
url: "https://wp-balsa-preview.draftbox.co/contact",
52+
url: "https://wp-libre-preview.draftbox.co/contact",
5353
},
5454
{
5555
label: "External Link",

gatsby-wordpress-theme-libre/README.md

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,75 @@ If you want to add this blog theme to an existing site, follow these instruction
4848
```js
4949
//siteConfig.js
5050
module.exports = {
51-
siteUrl: "http://localhost:9000", // Site domain. Do not include a trailing slash!
51+
siteUrl: "https://wp-libre-preview.draftbox.co", // Site domain. Do not include a trailing slash!
5252

53-
postsPerPage: 2, // Number of posts shown on paginated pages (changes this requires sometimes to delete the cache)
53+
postsPerPage: 10, // Number of posts shown on paginated pages (changes this requires sometimes to delete the cache)
5454

55-
siteTitleMeta: "Wordpress Gatsby Starter", // This allows an alternative site title for meta data for pages.
55+
siteTitleMeta: "Built with Draftbox", // This allows an alternative site title for meta data for pages.
5656
siteDescriptionMeta:
57-
"A starter template to build amazing static websites with Wordpress and Gatsby", // This allows an alternative site description for meta data for pages.
57+
"Lightning fast, secure front-end for your WordPress or Ghost blog, without coding", // This allows an alternative site description for meta data for pages.
5858

5959
shareImageWidth: 1000, // Change to the width of your default share image
6060
shareImageHeight: 523, // Change to the height of your default share image
6161

62-
shortTitle: "Wordpress", // Used for App manifest e.g. Mobile Home Screen
62+
shortTitle: "Built with Draftbox", // Used for App manifest e.g. Mobile Home Screen
6363
siteIcon: "favicon.png", // Logo in /static dir used for SEO, RSS, and App manifest
6464
backgroundColor: "#e9e9e9", // Used for Offline Manifest
65-
themeColor: "#15171A" // Used for Offline Manifest
65+
themeColor: "#15171A", // Used for Offline Manifest
66+
apiUrl: "https://wordpress.theasdfghjkl.com",
67+
subscribeWidget: {
68+
title: "Subscribe to Draftbox",
69+
helpText: "Get the latest posts delivered right to your inbox.",
70+
successMessage: "Thanks for subscribing to Draftbox.",
71+
},
72+
header: {
73+
navigation: [
74+
{
75+
label: "Home",
76+
url: "https://wp-libre-preview.draftbox.co/",
77+
},
78+
{
79+
label: "Contact",
80+
url: "https://wp-libre-preview.draftbox.co/contact",
81+
},
82+
],
83+
},
84+
footer: {
85+
copyright: "Built with Draftbox",
86+
navigation: [
87+
{
88+
label: "Home",
89+
url: "https://wp-libre-preview.draftbox.co/",
90+
},
91+
{
92+
label: "Sitemap",
93+
url: "https://wp-libre-preview.draftbox.co/sitemap.xml",
94+
},
95+
{
96+
label: "RSS",
97+
url: "https://wp-libre-preview.draftbox.co/rss.xml",
98+
},
99+
{
100+
label: "Contact",
101+
url: "https://wp-libre-preview.draftbox.co/contact",
102+
},
103+
{
104+
label: "External Link",
105+
url: "https://spectrum.chat/gatsby-js/themes?tab=posts",
106+
},
107+
],
108+
},
109+
socialLinks: {
110+
twitter: "https://twitter.com/draftboxhq",
111+
facebook: "https://facebook.com/",
112+
instagram: "https://www.instagram.com/",
113+
linkedin: "https://linkedin.com/",
114+
github: "https://github.com/draftbox-co",
115+
},
116+
contactWidget: {
117+
title: "Contact Built with Draftbox",
118+
successMessage: "We’ll get in touch with you soon.",
119+
},
66120
};
67121
```
68122

@@ -115,20 +169,22 @@ If your blog is hosted on wordpress.com you will have to add few extra keys for
115169
resolve: `@draftbox-co/gatsby-wordpress-theme-libre`,
116170
options: {
117171
wordpressConfig,
118-
siteConfig: siteConfig
119-
}
120-
}
121-
]
172+
siteConfig: siteConfig,
173+
},
174+
},
175+
],
122176
};
123177
```
124178

125179
## Authors
180+
126181
- Arun Priyadarshi ([@Gunnerforlife](https://github.com/Gunnerforlife)) – [Draftbox](https://draftbox.co)
127182
- Keyur Raval ([@thandaanda](https://github.com/thandaanda)) – [Draftbox](https://draftbox.co)
128183
- Shyam Lohar ([@shyamlohar](https://github.com/shyamlohar)) – [Draftbox](https://draftbox.co)
129184
- Tanmay Desai ([@tanmaydesai89](https://github.com/tanmaydesai89)) – [Draftbox](https://draftbox.co)
130185

131186
## Contributions
187+
132188
PRs are welcome! Consider contributing to this project if you are missing feature that is also useful for others.
133189

134190
# Copyright & License

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ exports.createSchemaCustomization = ({ actions, schema }) => {
5050
},
5151
});
5252

53+
createFieldExtension({
54+
name: "permaLinkSlug",
55+
extend(options, prevFieldConfig) {
56+
return {
57+
resolve(source, context) {
58+
if (source.link) {
59+
const pathName = new URL(source.link).pathname;
60+
return pathName;
61+
} else {
62+
return "";
63+
}
64+
},
65+
};
66+
},
67+
});
68+
5369
createFieldExtension({
5470
name: "plainExcerpt",
5571
extend() {
@@ -108,6 +124,7 @@ exports.createSchemaCustomization = ({ actions, schema }) => {
108124
plainTitle: String @plainTitle
109125
tags_custom: [wordpress__TAG] @tags_custom
110126
featured_media_custom: wordpress__wp_media @featured_media_custom
127+
permaLinkSlug: String @permaLinkSlug
111128
}
112129
`);
113130

@@ -203,7 +220,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
203220
edges {
204221
node {
205222
id
206-
slug
223+
slug: permaLinkSlug
207224
}
208225
}
209226
}
@@ -261,7 +278,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
261278

262279
posts.forEach((post, i, arr) => {
263280
createPage({
264-
path: `/${post.node.slug}`,
281+
path: `${post.node.slug}`,
265282
component: postTemplate,
266283
context: {
267284
slug: post.node.slug,
@@ -271,7 +288,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
271288
});
272289

273290
createPage({
274-
path: `/${post.node.slug}/amp`,
291+
path: `${post.node.slug}amp`,
275292
component: postAmpTemplate,
276293
context: {
277294
slug: post.node.slug,

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.27",
3+
"version": "1.0.28",
44
"license": "MIT",
55
"resolutions": {
66
"sharp": "0.23.4"

gatsby-wordpress-theme-libre/src/amp-styles/post.amp.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,3 +636,36 @@ select {
636636
float: left;
637637
width: 45%;
638638
}
639+
640+
amp-img img {
641+
object-fit: contain;
642+
}
643+
644+
.tags .tag {
645+
margin-left: 10px;
646+
color: cornflowerblue;
647+
}
648+
649+
.tag:hover {
650+
color: black;
651+
}
652+
653+
.comment-button-container {
654+
margin: 2.25rem auto;
655+
text-align: center;
656+
}
657+
658+
.comment-button-container button {
659+
background: transparent;
660+
border-style: solid;
661+
border-radius: 4px;
662+
border-width: 1px;
663+
border-color: darkgray;
664+
padding: 8px 22px;
665+
}
666+
667+
.comment-button-container a {
668+
color: cornflowerblue;
669+
font-weight: 600;
670+
text-decoration: none;
671+
}

gatsby-wordpress-theme-libre/src/templates/post.amp.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const PostTemplate = ({ data, location, pageContext }) => {
1515
<nav className="blog-title">
1616
<Link to="/">
1717
<span
18-
dangerouslySetInnerHTML={{ __html: pageContext.title }}
18+
dangerouslySetInnerHTML={{ __html: data.wordpressPost.title }}
1919
></span>
2020
</Link>
2121
</nav>
@@ -64,6 +64,24 @@ const PostTemplate = ({ data, location, pageContext }) => {
6464
className="post-content"
6565
dangerouslySetInnerHTML={{ __html: data.wordpressPost.content }}
6666
></section>
67+
68+
{data.wordpressPost.tags && data.wordpressPost.tags.length > 0 && (
69+
<div className="tags">
70+
<span>Tag:</span>
71+
<a
72+
className="tag"
73+
href={`/tag/${data.wordpressPost.tags[0].slug}`}
74+
>
75+
{data.wordpressPost.tags[0].name}
76+
</a>
77+
</div>
78+
)}
79+
80+
<div className="comment-button-container">
81+
<button>
82+
<a href={`${data.wordpressPost.slug}`}>Leave a comment</a>
83+
</button>
84+
</div>
6785
</article>
6886
</main>
6987
</>
@@ -74,10 +92,10 @@ export default PostTemplate;
7492

7593
export const pageQuery = graphql`
7694
query($slug: String!) {
77-
wordpressPost(slug: { eq: $slug }) {
95+
wordpressPost(permaLinkSlug: { eq: $slug }) {
7896
title
7997
plainExcerpt
80-
slug
98+
slug: permaLinkSlug
8199
content
82100
date(formatString: "DD MMMM YYYY")
83101
featured_media: featured_media_custom {
@@ -94,6 +112,10 @@ export const pageQuery = graphql`
94112
name
95113
slug
96114
}
115+
tags: tags_custom {
116+
name
117+
slug
118+
}
97119
}
98120
}
99121
`;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,18 +294,18 @@ export default Post;
294294

295295
export const postQuery = graphql`
296296
query($slug: String, $prev: String, $next: String) {
297-
wordpressPost(slug: { eq: $slug }) {
297+
wordpressPost(permaLinkSlug: { eq: $slug }) {
298298
...WordPressPostData
299299
}
300300
301301
prev: wordpressPost(id: { eq: $prev }) {
302302
title
303-
slug
303+
slug: permaLinkSlug
304304
}
305305
306306
next: wordpressPost(id: { eq: $next }) {
307307
title
308-
slug
308+
slug: permaLinkSlug
309309
}
310310
}
311311
`;

gatsby-wordpress-theme-libre/src/utils/fragments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const wordPressPostData = graphql`
1818
content
1919
excerpt
2020
plainExcerpt
21-
slug
21+
slug: permaLinkSlug
2222
categories {
2323
name
2424
slug

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,11 +1738,6 @@
17381738
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-0.0.30.tgz#dc1e40f7af3b9c815013a7860e6252f6352a84df"
17391739
integrity sha512-orGL5LXERPYsLov6CWs3Fh6203+dXzJkR7OnddIr2514Hsecwc8xRpzCapshBbKFImCsvS/mk6+FWiN5LyZJAQ==
17401740

1741-
"@types/eslint-visitor-keys@^1.0.0":
1742-
version "1.0.0"
1743-
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
1744-
integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==
1745-
17461741
"@types/events@*":
17471742
version "3.0.0"
17481743
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
@@ -1918,6 +1913,11 @@
19181913
version "2.30.0"
19191914
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.30.0.tgz#7681c305a6f4341ae2579f5e3a75846c29eee9ce"
19201915
integrity sha512-9kDOxzp0K85UnpmPJqUzdWaCNorYYgk1yZmf4IKzpeTlSAclnFsrLjfwD9mQExctLoLoGAUXq1co+fbr+3HeFw==
1916+
dependencies:
1917+
"@types/eslint-visitor-keys" "^1.0.0"
1918+
"@typescript-eslint/experimental-utils" "2.30.0"
1919+
"@typescript-eslint/typescript-estree" "2.30.0"
1920+
eslint-visitor-keys "^1.1.0"
19211921

19221922
"@typescript-eslint/typescript-estree@2.30.0":
19231923
version "2.30.0"

0 commit comments

Comments
 (0)