Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Define index route in frontmatter #721

Merged
merged 3 commits into from Sep 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -16,6 +16,10 @@
([ref #433](https://github.com/MoOx/phenomic/issues/433) - @MoOx)
- Changed: error messages for bad configuration are now more readable
([#672](https://github.com/MoOx/phenomic/issues/672) - @MoOx)
- Fixed: front matter ``route`` can use ``/`` to define the homepage
([#721](https://github.com/MoOx/phenomic/pull/721) - @thangngoc89)
single string is passed as a child.
(@MoOx)
- Added: 🚀 Hard source Webpack plugin to improve performance by more than 300%
You can enable this **experimental** feature by add
``"webpackHardCache": true`` in your ``package.json`` ``phenomic`` section.
Expand Down
5 changes: 4 additions & 1 deletion src/components/PageContainer/component.js
Expand Up @@ -27,7 +27,10 @@ type Context = {

// react-router does not return leading and trailing slashes
// so we need to normalize according to collection data
const splatToUrl = (string) => ("/" + urlify(string))
const splatToUrl = (string) => {
const url = "/" + urlify(string)
return (url === "//") ? "/" : url
}

const isDevelopment = (): boolean => process.env.NODE_ENV !== "production"
const isClient = (): boolean => typeof window !== "undefined"
Expand Down
@@ -0,0 +1,4 @@
---
title: custom route root index
route: /
---
13 changes: 12 additions & 1 deletion src/phenomic-loader/__tests__/index.js
Expand Up @@ -86,6 +86,17 @@ test.cb("phenomic loader", (t) => {
"should create a proper json for custom route with an extension"
)

const customRouteRootIndex = stats.compilation.assets[
// fixtures/custom-route-root-index.md
// -> fixtures/index.html
"index.html" +
".8817d2a1fab9dfb9b4b52cd6ee7529ab.json"
]
t.truthy(
customRouteRootIndex && customRouteRootIndex._value,
"should create a proper json for custom route with an extension"
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test does not seems to add some value here. What is this supposed to check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this PR, webpack doesn't emit /index.html file and its json file.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha OUCH.


t.end()
}
)
Expand Down Expand Up @@ -140,7 +151,7 @@ test.cb("phenomic loader can be used with plugins", (t) => {
"dumb"
)
})
t.plan(2+4) // 2, err, warn, 4 => array
t.plan(2+5) // 2, err, warn, 5 => array
t.end()
}
)
Expand Down
4 changes: 3 additions & 1 deletion src/phenomic-loader/index.js
Expand Up @@ -52,13 +52,15 @@ module.exports = function(input: string) {
})
}, {})

const tmpUrl = urlify(
let tmpUrl = urlify(
pluginsResult.head && pluginsResult.head.route
// custom route
? pluginsResult.head.route
// default route
: relativePath
)
tmpUrl = (tmpUrl.substring(0, 1) === "/") ? tmpUrl.slice(1) : tmpUrl

const url = urlify(tmpUrl)
const resourceUrl = urlify(tmpUrl, true)
const contentHash = loaderUtils.getHashDigest(input)
Expand Down