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

Commit 19b7702

Browse files
2 parents 71e0a7a + b670fed commit 19b7702

File tree

88 files changed

+8753
-1307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+8753
-1307
lines changed

.firebase/hosting.d3d3.cache

Lines changed: 386 additions & 0 deletions
Large diffs are not rendered by default.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ Thumbs.db
2424
UserInterfaceState.xcuserstate
2525
.env
2626
linters/sass-lint.html
27+
src/pages/app-blog-post/prerender-blog-data.ts
28+
src/butter-api/butter-api-key.js

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ https://developers.google.com/speed/webp/docs/precompiled
4141
brew install webp
4242
```
4343

44-
#### Make Sure .webp Images are available by running the following commands:
44+
#### Make Sure .webp Images are available by running the following commands inside the root folder:
4545
```
4646
for file in src/assets/*.jpg; do cwebp -q 75 "$file" -o "${file%.jpg}.webp"; done
4747
```
@@ -54,6 +54,28 @@ for file in src/assets/*.png; do cwebp -q 75 "$file" -o "${file%.png}.webp"; don
5454
for file in src/assets/*.jpeg; do cwebp -q 75 "$file" -o "${file%.jpeg}.webp"; done
5555
```
5656

57+
### Blog Setup
58+
By default, the public version of this project does not contain an API key for the [ButterCMS](https://buttercms.com/) blog content management system. You will need to add your own ButterCMS API key in order to make this project work.
59+
60+
The necessary file for inserting the ButterCMS API key will be auto-generated by running
61+
```
62+
node scripts/get-butter.js
63+
```
64+
65+
After that, use your text editor and open the file:
66+
```
67+
src/butter-api/butter-api-key.ts
68+
```
69+
70+
and enter your Butter API key between the single quotes '':
71+
```
72+
export const BUTTER_API_KEY = '';
73+
```
74+
to
75+
```
76+
export const BUTTER_API_KEY = 'your API token goes here';
77+
```
78+
5779
### Running This Application
5880
```
5981
npm run dev
@@ -116,12 +138,22 @@ For every commit, it will ensure files are linted and that the code is formatted
116138

117139
If a developer went through providing all the information during a `npm run cz` only to find that there were issues with their commit. They may fix them and instruct commitizen to try the commit again with `npm run cz -- --retry`
118140

141+
## Blog Integration
119142

120-
## Deployment
143+
This project uses [ButterCMS](https://buttercms.com/) as a headless content management system. When a user accesses the deployed site, the blog data will be loaded from the ButterCMS API via AJAX. However, the blog data is also utilized in prerendering the site, to improve SEO. Before any build (dev, prod, prerender), the get-butter.js script is run to retrieve the blog data and stored in pages/blog-post/prerender-blog-data.ts. This file is git-ignored so that the repo is not cluttered with blog content.
144+
145+
The project also utilizes webhooks from [ButterCMS](https://buttercms.com/docs/api/?javascript#webhooks) and [Travis](https://docs.travis-ci.com/user/triggering-builds) to keep the prerendered blog content up to date. Whenever a new blog post is published, Butter's webook invokes the cloud function rebuildMaster, which relays the information to the Travis API, which in turn will trigger a rebuild and redeploy of the master branch. Butter's webhooks are managed in the ButterCMS portal.
121146

147+
### Featured Post
148+
149+
The featured post is managed in the ButterCMS portal. To make a post featured, it must be given a tag of 'featured'. The actual featured post will be the most recently published post with the featured tag. Currently, this post will also appear in the regular list of posts.
150+
151+
152+
## Deployment
122153
```
123154
npm run prepublish
124155
```
156+
Note that this will synchronously retrieve the blog post data from Butter CMS before building, so that it can be included in the prerender.
125157

126158
_Note: You may have to install firebase-tools via ```npm install -g firebase-tools``` and then authenticate via command line on your local machine to firebase_
127159

firebase.json

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,46 @@
66
"**/.*",
77
"**/node_modules/**"
88
],
9-
"headers": [ {
10-
"source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
11-
"headers" : [ {
12-
"key" : "Access-Control-Allow-Origin",
13-
"value" : "*"
14-
} ]
15-
}, {
16-
"source" : "**/*.@(jpg|jpeg|gif|png|js)",
17-
"headers" : [ {
18-
"key" : "Cache-Control",
19-
"value" : "max-age=86400"
20-
} ]
21-
} , {
22-
"source" : "**/*.@(js)",
23-
"headers" : [ {
24-
"key" : "Cache-Control",
25-
"value" : "max-age=7200"
26-
} ]
27-
}],
28-
9+
"headers": [
10+
{
11+
"source": "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
12+
"headers": [
13+
{
14+
"key": "Access-Control-Allow-Origin",
15+
"value": "*"
16+
}
17+
]
18+
},
19+
{
20+
"source": "**/*.@(jpg|jpeg|gif|png|js)",
21+
"headers": [
22+
{
23+
"key": "Cache-Control",
24+
"value": "max-age=86400"
25+
}
26+
]
27+
},
28+
{
29+
"source": "**/*.@(js)",
30+
"headers": [
31+
{
32+
"key": "Cache-Control",
33+
"value": "max-age=7200"
34+
}
35+
]
36+
}
37+
],
2938
"rewrites": [
3039
{
3140
"source": "**",
3241
"destination": "/index.html"
3342
}
3443
]
44+
},
45+
"functions": {
46+
"predeploy": [
47+
"npm --prefix \"$RESOURCE_DIR\" run lint",
48+
"npm --prefix \"$RESOURCE_DIR\" run build"
49+
]
3550
}
3651
}

functions/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Compiled JavaScript files
2+
**/*.js
3+
**/*.js.map
4+
5+
# Typescript v1 declaration files
6+
typings/
7+
8+
node_modules/

0 commit comments

Comments
 (0)