Skip to content

Commit 73e84fa

Browse files
committed
Fixed blog.html redirect
1 parent 8f6bfc2 commit 73e84fa

File tree

5 files changed

+62
-71
lines changed

5 files changed

+62
-71
lines changed

www/gatsby-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module.exports = {
2020
},
2121
plugins: [
2222
'gatsby-transformer-authors-yaml',
23+
'gatsby-plugin-netlify',
2324
'gatsby-plugin-glamor',
2425
'gatsby-plugin-react-next',
2526
{

www/gatsby-node.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ exports.modifyWebpackConfig = ({ config, stage }) => {
2828
};
2929

3030
exports.createPages = async ({graphql, boundActionCreators}) => {
31-
const {createPage} = boundActionCreators;
31+
const {createPage, createRedirect} = boundActionCreators;
3232

3333
const blogTemplate = resolve('./src/templates/blog.js');
3434
const communityTemplate = resolve('./src/templates/community.js');
@@ -129,10 +129,7 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
129129
}
130130
});
131131

132-
/* TODO Register '/blog.html' redirect to most recent blog entry.
133-
* And delete redundant 'pages/blog.html.js'
134-
* github.com/gatsbyjs/gatsby/pull/1068
135-
const mostRecentBlogMarkdown = await graphql(`
132+
const newestBlogEntry = await graphql(`
136133
{
137134
allMarkdownRemark(
138135
limit: 1,
@@ -149,7 +146,12 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
149146
}
150147
}
151148
`);
152-
*/
149+
150+
// Blog landing page should always show the most recent blog entry.
151+
createRedirect({
152+
fromPath: '/blog.html',
153+
toPath: newestBlogEntry.data.allMarkdownRemark.edges[0].node.fields.slug,
154+
});
153155
};
154156

155157
// Parse date information out of blog post filename.

www/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"gatsby-plugin-glamor": "^1.6.4",
1212
"gatsby-plugin-google-analytics": "^1.0.4",
1313
"gatsby-plugin-manifest": "^1.0.4",
14+
"gatsby-plugin-netlify": "^1.0.2",
1415
"gatsby-plugin-offline": "^1.0.4",
1516
"gatsby-plugin-react-helmet": "^1.0.3",
1617
"gatsby-plugin-react-next": "^1.0.3",

www/src/pages/blog.html.js

Lines changed: 0 additions & 54 deletions
This file was deleted.

www/yarn.lock

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,14 @@ chalk@1.1.3, chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3:
16421642
strip-ansi "^3.0.0"
16431643
supports-color "^2.0.0"
16441644

1645+
chalk@^2.0:
1646+
version "2.1.0"
1647+
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e"
1648+
dependencies:
1649+
ansi-styles "^3.1.0"
1650+
escape-string-regexp "^1.0.5"
1651+
supports-color "^4.0.0"
1652+
16451653
chalk@^2.0.1:
16461654
version "2.0.1"
16471655
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.0.1.tgz#dbec49436d2ae15f536114e76d14656cdbc0f44d"
@@ -3366,6 +3374,15 @@ gatsby-plugin-manifest@^1.0.4:
33663374
babel-runtime "^6.26.0"
33673375
bluebird "^3.5.0"
33683376

3377+
gatsby-plugin-netlify@^1.0.2:
3378+
version "1.0.2"
3379+
resolved "https://registry.yarnpkg.com/gatsby-plugin-netlify/-/gatsby-plugin-netlify-1.0.2.tgz#4c84287efda9bb36ffd5c10bfb8fe135fc51929e"
3380+
dependencies:
3381+
babel-runtime "^6.26.0"
3382+
lodash "^4.17.4"
3383+
pify "3.0.0"
3384+
webpack-assets-manifest "^1.0.0"
3385+
33693386
gatsby-plugin-offline@^1.0.4:
33703387
version "1.0.9"
33713388
resolved "https://registry.yarnpkg.com/gatsby-plugin-offline/-/gatsby-plugin-offline-1.0.9.tgz#5d5879caf81a6e762984341f6eba765818d92320"
@@ -3488,8 +3505,8 @@ gatsby-source-filesystem@^1.4.4:
34883505
slash "^1.0.0"
34893506

34903507
gatsby-transformer-remark@^1.7.2:
3491-
version "1.7.9"
3492-
resolved "https://registry.yarnpkg.com/gatsby-transformer-remark/-/gatsby-transformer-remark-1.7.9.tgz#fe1d2867aca54c62e9bef33c73cc19e2a90674e0"
3508+
version "1.7.10"
3509+
resolved "https://registry.yarnpkg.com/gatsby-transformer-remark/-/gatsby-transformer-remark-1.7.10.tgz#0e0df5495a189b0db601ca73c48c66b70e6055be"
34933510
dependencies:
34943511
babel-runtime "^6.26.0"
34953512
bluebird "^3.5.0"
@@ -3514,8 +3531,8 @@ gatsby-transformer-sharp@^1.6.1:
35143531
image-size "^0.6.0"
35153532

35163533
gatsby@^1.9.9:
3517-
version "1.9.40"
3518-
resolved "https://registry.yarnpkg.com/gatsby/-/gatsby-1.9.40.tgz#e4c713ec9ad849d4f5e455e595f941abd5a05ede"
3534+
version "1.9.42"
3535+
resolved "https://registry.yarnpkg.com/gatsby/-/gatsby-1.9.42.tgz#6792442e9b7f69e7d2b3e76b63b468de097c61c6"
35193536
dependencies:
35203537
async "^2.1.2"
35213538
babel-code-frame "^6.22.0"
@@ -5139,6 +5156,14 @@ lodash.foreach@^4.3.0:
51395156
version "4.5.0"
51405157
resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53"
51415158

5159+
lodash.get@^4.0:
5160+
version "4.4.2"
5161+
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
5162+
5163+
lodash.has@^4.0:
5164+
version "4.5.2"
5165+
resolved "https://registry.yarnpkg.com/lodash.has/-/lodash.has-4.5.2.tgz#d19f4dc1095058cccbe2b0cdf4ee0fe4aa37c862"
5166+
51425167
lodash.isarguments@^3.0.0:
51435168
version "3.1.0"
51445169
resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a"
@@ -5167,6 +5192,10 @@ lodash.keys@^3.0.0:
51675192
lodash.isarguments "^3.0.0"
51685193
lodash.isarray "^3.0.0"
51695194

5195+
lodash.keys@^4.0:
5196+
version "4.2.0"
5197+
resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-4.2.0.tgz#a08602ac12e4fb83f91fc1fb7a360a4d9ba35205"
5198+
51705199
lodash.map@^4.4.0:
51715200
version "4.6.0"
51725201
resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3"
@@ -5179,7 +5208,7 @@ lodash.memoize@^4.1.2:
51795208
version "4.1.2"
51805209
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
51815210

5182-
lodash.merge@^4.4.0:
5211+
lodash.merge@^4.0, lodash.merge@^4.4.0:
51835212
version "4.6.0"
51845213
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.0.tgz#69884ba144ac33fe699737a6086deffadd0f89c5"
51855214

@@ -5195,7 +5224,7 @@ lodash.padstart@^4.1.0:
51955224
version "4.6.1"
51965225
resolved "https://registry.yarnpkg.com/lodash.padstart/-/lodash.padstart-4.6.1.tgz#d2e3eebff0d9d39ad50f5cbd1b52a7bce6bb611b"
51975226

5198-
lodash.pick@^4.2.1:
5227+
lodash.pick@^4.0, lodash.pick@^4.2.1:
51995228
version "4.4.0"
52005229
resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3"
52015230

@@ -5604,7 +5633,7 @@ mixin-deep@^1.1.3:
56045633
for-in "^1.0.2"
56055634
is-extendable "^0.1.1"
56065635

5607-
"mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1:
5636+
"mkdirp@>=0.5 0", mkdirp@^0.5, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1:
56085637
version "0.5.1"
56095638
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
56105639
dependencies:
@@ -6219,14 +6248,14 @@ pez@1.x.x:
62196248
hoek "2.x.x"
62206249
nigel "1.x.x"
62216250

6251+
pify@3.0.0, pify@^3.0.0:
6252+
version "3.0.0"
6253+
resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"
6254+
62226255
pify@^2.0.0, pify@^2.3.0:
62236256
version "2.3.0"
62246257
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
62256258

6226-
pify@^3.0.0:
6227-
version "3.0.0"
6228-
resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"
6229-
62306259
pinkie-promise@^2.0.0:
62316260
version "2.0.1"
62326261
resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa"
@@ -9053,6 +9082,18 @@ watchpack@^0.2.1:
90539082
chokidar "^1.0.0"
90549083
graceful-fs "^4.1.2"
90559084

9085+
webpack-assets-manifest@^1.0.0:
9086+
version "1.0.0"
9087+
resolved "https://registry.yarnpkg.com/webpack-assets-manifest/-/webpack-assets-manifest-1.0.0.tgz#54a1bc4036e2eed2b3ce1fd6a7e31c09be99538a"
9088+
dependencies:
9089+
chalk "^2.0"
9090+
lodash.get "^4.0"
9091+
lodash.has "^4.0"
9092+
lodash.keys "^4.0"
9093+
lodash.merge "^4.0"
9094+
lodash.pick "^4.0"
9095+
mkdirp "^0.5"
9096+
90569097
webpack-configurator@^0.3.0:
90579098
version "0.3.1"
90589099
resolved "https://registry.yarnpkg.com/webpack-configurator/-/webpack-configurator-0.3.1.tgz#d16802afa674101a0cbfa6fc344d415c9649540b"

0 commit comments

Comments
 (0)