diff --git a/gridsome.config.js b/gridsome.config.js index e6f1e1e..3035999 100644 --- a/gridsome.config.js +++ b/gridsome.config.js @@ -4,6 +4,12 @@ module.exports = { siteDescription: 'The professional publishing platform', titleTemplate: `%s - Gridsome`, + templates: { + GhostPost: '/:slug', + GhostTag: '/tag/:slug', + GhostAuthor: '/author/:slug' + }, + plugins: [ { use: '@gridsome/plugin-google-analytics', @@ -12,29 +18,16 @@ module.exports = { } }, { - use: '@gridsome/source-filesystem', + use: '@gridsome/source-ghost', options: { - path: 'blog/*.md', - typeName: 'Post', - route: '/:slug', - refs: { - author: 'Author', - tags: { - typeName: 'Tag', - route: '/tag/:title', - create: true - } + baseUrl: process.env.GHOST_API_URL, + contentKey: process.env.GHOST_CONTENT_KEY, + routes: { + post: '/:slug', + page: '/:slug', + author: '/author/:slug' } } }, - { - use: '@gridsome/source-filesystem', - options: { - // TODO Use yaml file as data source - path: 'data/author/*.md', - typeName: 'Author', - route: '/author/:id' - } - } ] } diff --git a/package.json b/package.json index 568c350..7cbb5bb 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,14 @@ }, "dependencies": { "@gridsome/plugin-google-analytics": "^0.1.0", - "@gridsome/source-filesystem": "^0.3.0", - "@gridsome/transformer-remark": "^0.2.0", - "gridsome": "^0.5.0", - "node-sass": "^4.11.0", + "@gridsome/source-filesystem": "^0.6.0", + "@gridsome/source-ghost": "^0.2.0", + "@gridsome/transformer-remark": "^0.3.0", + "gridsome": "^0.7.0" + }, + "devDependencies": { + "node-sass": "^4.12.0", "sass-loader": "^7.1.0", "vue-moment": "^4.0.0" } -} \ No newline at end of file +} diff --git a/src/components/Card.vue b/src/components/Card.vue index ce7e151..125549b 100644 --- a/src/components/Card.vue +++ b/src/components/Card.vue @@ -1,8 +1,8 @@ diff --git a/src/pages/Index.vue b/src/pages/Index.vue index 72fe861..17f06d7 100644 --- a/src/pages/Index.vue +++ b/src/pages/Index.vue @@ -1,15 +1,20 @@ - query Home ($page: Int) { - allPost (page: $page, order: ASC) { - edges { - node { - id - title - path - tags { - title - } - image - content - author { - id - name - image - } - timeToRead +{ + posts: allGhostPost( + sortBy: "published_at", + order: DESC, + ) { + edges { + node { + title + description: excerpt + date: published_at (format: "D. MMMM YYYY") + path + slug + id + coverImage: feature_image + authors { + name + url + slug + image: profile_image + } + tags { + name + slug } } } } - \ No newline at end of file +} + + + + query Admin { + metadata { + siteName + siteDescription + siteUrl + ghost { + title + url + logo + description + navigation { + url + label + } + } + } + } + diff --git a/src/templates/Author.vue b/src/templates/GhostAuthor.vue similarity index 85% rename from src/templates/Author.vue rename to src/templates/GhostAuthor.vue index 1371634..0c87bd2 100644 --- a/src/templates/Author.vue +++ b/src/templates/GhostAuthor.vue @@ -9,7 +9,7 @@

{{ $page.author.bio }}

-
{{ $page.author.location }} +
{{ $page.author.location }}
@@ -102,34 +102,36 @@ - query Author ($id: String!) { - author (id: $id) { + query Author ($path: String!) { + author: ghostAuthor (path: $path) { name - image + image: profile_image bio - location website - twitter - facebook belongsTo { edges { node { - ...on Post { - id + ...on GhostPost { title - author { - id - name - image - } + description: excerpt + date: published_at (format: "D. MMMM YYYY") path - image - content - timeToRead + slug + id + coverImage: feature_image + authors { + name + url + slug + image: profile_image + } + tags { + name + } } } } } } } - \ No newline at end of file + diff --git a/src/templates/Post.vue b/src/templates/GhostPost.vue similarity index 76% rename from src/templates/Post.vue rename to src/templates/GhostPost.vue index cec0685..6f67137 100644 --- a/src/templates/Post.vue +++ b/src/templates/GhostPost.vue @@ -16,8 +16,8 @@ / {{ $page.post.tags.title.replace('-', ' ') }} + :href="$page.post.tags[0].path" + >{{ $page.post.tags[0].title.replace('-', ' ') }}

{{ $page.post.title }}

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