diff --git a/gridsome.config.js b/gridsome.config.js index 71a6c0fdc..59e049b5b 100644 --- a/gridsome.config.js +++ b/gridsome.config.js @@ -59,6 +59,24 @@ module.exports = { } } } + }, + + { + use: '@gridsome/source-filesystem', + options: { + typeName: 'Project', + path: './content/project/**/*.md', + templates: { + Project: '/project/:id' + }, + refs: { + author: 'Person', + tags: { + typeName: 'Tag', + create: true + } + } + } } ], transformers: { @@ -85,5 +103,9 @@ module.exports = { path: '/tags/:id', component: '~/templates/Tag.vue' }], + Project: [{ + path: '/project/:id', + component: '~/templates/Project.vue' + }], } } diff --git a/gridsome.server.js b/gridsome.server.js index 5df953649..e1971538c 100644 --- a/gridsome.server.js +++ b/gridsome.server.js @@ -27,6 +27,15 @@ module.exports = function (api) { ...options }; } + + if (options.internal.typeName === 'Project') { + options.countries = (typeof options.tags === 'string') ? options.tags.split(',').map(string => string.trim()) : options.tags; + options.cities = (typeof options.tags === 'string') ? options.tags.split(',').map(string => string.trim()) : options.tags; + options.author = (typeof options.author === 'string') ? options.author.split(',').map(string => string.trim()) : options.author; + return { + ...options + }; + } }) api.createPages(async ({ @@ -68,4 +77,45 @@ module.exports = function (api) { }); }); + + // api.createPages(async ({ + // graphql, + // createPage + // }) => { + // // Use the Pages API here: https://gridsome.org/docs/pages-api + // const { + // data + // } = await graphql(`{ + // allProject { + // edges { + // previous { + // id + // } + // next { + // id + // } + // node { + // id + // path + // } + // } + // } + // } + // `); + + // data.allProject.edges.forEach(function (element) { + // console.log(element) + // createPage({ + // path: element.node.path, + // component: './src/templates/Project.vue', + // context: { + // previousElement: (element.previous) ? element.previous.id : '##empty##', + // nextElement: (element.next) ? element.next.id : '##empty##', + // id: element.node.id + // } + // }); + + // }); + + // }); } \ No newline at end of file diff --git a/src/components/ProjectListItem.vue b/src/components/ProjectListItem.vue new file mode 100644 index 000000000..6249bdd96 --- /dev/null +++ b/src/components/ProjectListItem.vue @@ -0,0 +1,65 @@ + + + + + \ No newline at end of file diff --git a/src/pages/Projects.vue b/src/pages/Projects.vue new file mode 100644 index 000000000..76704e716 --- /dev/null +++ b/src/pages/Projects.vue @@ -0,0 +1,55 @@ + + + + +query($page:Int) { + entries: allProject(perPage: 9, page: $page) @paginate { + totalCount + pageInfo { + totalPages + currentPage + } + edges { + node { + title + members + rank + + excerpt + image(width:800) + path + timeToRead + author { + id + + image(width:64, height:64, fit:inside) + path + } + } + } + } +} + + + + diff --git a/src/templates/Project.vue b/src/templates/Project.vue new file mode 100644 index 000000000..b3023e521 --- /dev/null +++ b/src/templates/Project.vue @@ -0,0 +1,144 @@ + + + + query($id: ID!, $page:Int) { + project(id: $id) { + id + title + status + countries + image(width:150, height:150) + image_caption + logo + cities + timeToRead + path + timeToRead + tags { + id + title + path + } + + + members + websites + private + + rank + excerpt + content + belongsTo(perPage: 5, page: $page) @paginate { + totalCount + pageInfo { + totalPages + currentPage + } + edges { + node { + ... on Person { + name + } + } + } + } + } + } + + +