From 9a0415d3ff6cdc7a6486410a5c42e80b5d916264 Mon Sep 17 00:00:00 2001 From: Hippo Date: Tue, 24 Dec 2019 13:38:50 +0530 Subject: [PATCH] Create view for Pages GhostPost and GhostPage are copies of each other: they conditionally render depending on whether the path matches a post or page. The reason for this workaround is that, otherwise, the router would show a 404 for non-matching posts even when a matching page existed, since they both lie under the same path. --- gridsome.config.js | 1 + src/pages/About.vue | 51 ----------- src/templates/GhostPage.vue | 165 ++++++++++++++++++++++++++++++++++++ src/templates/GhostPost.vue | 62 ++++++++++---- 4 files changed, 210 insertions(+), 69 deletions(-) delete mode 100644 src/pages/About.vue create mode 100644 src/templates/GhostPage.vue diff --git a/gridsome.config.js b/gridsome.config.js index fd1f2c1..e046ed7 100644 --- a/gridsome.config.js +++ b/gridsome.config.js @@ -9,6 +9,7 @@ module.exports = { templates: { GhostPost: '/:slug', + GhostPage: '/:slug', GhostTag: '/tag/:slug', GhostAuthor: '/author/:slug' }, diff --git a/src/pages/About.vue b/src/pages/About.vue deleted file mode 100644 index b0b3463..0000000 --- a/src/pages/About.vue +++ /dev/null @@ -1,51 +0,0 @@ - - - diff --git a/src/templates/GhostPage.vue b/src/templates/GhostPage.vue new file mode 100644 index 0000000..7da6653 --- /dev/null +++ b/src/templates/GhostPage.vue @@ -0,0 +1,165 @@ + + + + + query Post ($path: String!) { + post: ghostPost (path: $path) { + id + title + path + date: published_at (format: "D. MMMM YYYY") + tags { + id + slug + path + title: name + belongsTo { + edges { + node { + ... on GhostPost { + id + title + path + } + } + } + } + } + authors { + name + id + slug + image: profile_image + } + description: excerpt + content: html + image: feature_image + } + page: ghostPage (path: $path) { + id + title + path + date: updated_at (format: "D. MMMM YYYY") + description: excerpt + content: html + } + } + diff --git a/src/templates/GhostPost.vue b/src/templates/GhostPost.vue index 8d55c48..7da6653 100644 --- a/src/templates/GhostPost.vue +++ b/src/templates/GhostPost.vue @@ -12,18 +12,18 @@
-
- +
+ / {{ $page.post.tags[0].title.replace('-', ' ') }} + :href="thisPost.tags[0].path" + >{{ thisPost.tags[0].title.replace('-', ' ') }}
-

{{ $page.post.title }}

+

{{ thisPost.title }}

-
- +
+
@@ -37,8 +37,8 @@
- - + +