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

Commit c85b8ef

Browse files
committed
updated path property to new API CLOSES #79
1 parent 63b9557 commit c85b8ef

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/content/page.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@ export default function prepPage (meta, options, isDev) {
4343

4444
get path () {
4545
const { permalink } = this
46-
if (isDev || !options.routes) {return permalink}
47-
const dynamicRoute = options.routes.find(route => route.method === 'get')
48-
const nestedPath = /([^_][a-zA-z]*?)\/[^a-z_]*/
49-
const matchedPath = dynamicRoute.path.match(nestedPath)
50-
if (matchedPath && matchedPath[1] !== 'index') {
51-
return join(matchedPath[1] + permalink)
52-
} else {
53-
return permalink
46+
if (!options.page) return permalink
47+
if (isDev || !cached.path) {
48+
const nestedPath = /([^_][a-zA-z]*?)\/[^a-z_]*/
49+
const matchedPath = options.page.match(nestedPath)
50+
if (matchedPath && matchedPath[1] !== 'index') {
51+
cached.path = join(matchedPath[1] + permalink)
52+
} else {
53+
cached.path = permalink
54+
}
5455
}
56+
return cached.path
5557
},
5658

5759
get permalink () {

0 commit comments

Comments
 (0)