├── .gitignore ├── README.md ├── gridsome.config.js ├── gridsome.server.js ├── package-lock.json ├── package.json ├── src ├── components │ └── README.md ├── favicon.png ├── layouts │ ├── Default.vue │ └── README.md ├── main.js ├── pages │ ├── About.vue │ ├── Index.vue │ ├── README.md │ └── Showcase.vue └── templates │ ├── BookEntry.vue │ └── README.md └── static └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .cache 3 | .DS_Store 4 | src/.temp 5 | node_modules 6 | dist 7 | .env 8 | .env.* 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A simple Gridsome project 2 | ` 3 | ### 1. Install Gridsome CLI tool if you don't have 4 | 5 | `npm install --global @gridsome/cli` 6 | 7 | ### 2. Create a Gridsome project 8 | 9 | 1. `cd ` to open folder 10 | 2. `gridsome develop` to start local dev server at `http://localhost:8080` 11 | 3. Happy coding 🎉🙌 12 | -------------------------------------------------------------------------------- /gridsome.config.js: -------------------------------------------------------------------------------- 1 | // This is where project configuration and plugin options are located. 2 | // Learn more: https://gridsome.org/docs/config 3 | 4 | // Changes here requires a server restart. 5 | // To restart press CTRL + C in terminal and run `gridsome develop` 6 | 7 | module.exports = { 8 | siteName: 'Book Showcase', 9 | plugins: [] 10 | } -------------------------------------------------------------------------------- /gridsome.server.js: -------------------------------------------------------------------------------- 1 | // Server API makes it possible to hook into various parts of Gridsome 2 | // on server-side and add custom data to the GraphQL data layer. 3 | // Learn more: https://gridsome.org/docs/server-api 4 | 5 | // Changes here requires a server restart. 6 | // To restart press CTRL + C in terminal and run `gridsome develop` 7 | 8 | const axios = require('axios') 9 | 10 | bookISBNs = [ 11 | "0553211285", 12 | "9789875504950", 13 | "9780439203524", 14 | "9780883017500", 15 | "9781402766442", 16 | "9781585101634", 17 | "9780393044720", 18 | "9780143105947", 19 | "9780881033731" 20 | ] 21 | 22 | module.exports = function (api) { 23 | api.loadSource(async store => { 24 | // const { data } = await axios.get('https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/@OnsenMonaca') 25 | let books = [] 26 | 27 | for (const isbn of bookISBNs) { 28 | const res = await axios.get(`http://openlibrary.org/api/books?bibkeys=ISBN:${isbn}&format=json&jscmd=data`) 29 | 30 | if (res.data[`ISBN:${isbn}`]) { 31 | books.push(res.data[`ISBN:${isbn}`]) 32 | } 33 | } 34 | 35 | // const blogPosts = data.items.filter(item => item.categories.length > 0) 36 | 37 | const contentType = store.addContentType({ 38 | typeName: 'BookEntry', 39 | route: 'showcase/:id' 40 | }) 41 | 42 | for (const item of books) { 43 | contentType.addNode({ 44 | title: item.title, 45 | date: item.publish_date, 46 | fields: { 47 | ...item 48 | } 49 | }) 50 | } 51 | }) 52 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gridsome-static-site", 3 | "private": true, 4 | "scripts": { 5 | "build": "gridsome build", 6 | "develop": "gridsome develop", 7 | "explore": "gridsome explore" 8 | }, 9 | "dependencies": { 10 | "axios": "^0.21.1", 11 | "gridsome": "^0.5.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/components/README.md: -------------------------------------------------------------------------------- 1 | Add components that will be imported to Pages and Layouts to this folder. 2 | Learn more about components here: https://gridsome.org/docs/components 3 | 4 | You can delete this file. -------------------------------------------------------------------------------- /src/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cvetkovskin/gridsome-book-showcase/69c3a4506e9488dc899a6be275157c8ec4e5b221/src/favicon.png -------------------------------------------------------------------------------- /src/layouts/Default.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | query { 19 | metaData { 20 | siteName 21 | } 22 | } 23 | 24 | 25 | 52 | -------------------------------------------------------------------------------- /src/layouts/README.md: -------------------------------------------------------------------------------- 1 | Layout components are used to wrap pages and templates. Layouts should contain components like headers, footers or sidebars that will be used across the site. 2 | 3 | Learn more about Layouts: https://gridsome.org/docs/layouts 4 | 5 | You can delete this file. -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | // This is the main.js file. Import global CSS and scripts here. 2 | // The Client API can be used here. Learn more: gridsome.org/docs/client-api 3 | 4 | import DefaultLayout from '~/layouts/Default.vue' 5 | 6 | export default function (Vue, { router, head, isClient }) { 7 | // Set default layout as a global component 8 | Vue.component('Layout', DefaultLayout) 9 | } 10 | -------------------------------------------------------------------------------- /src/pages/About.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 15 | -------------------------------------------------------------------------------- /src/pages/Index.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 28 | 29 | 34 | -------------------------------------------------------------------------------- /src/pages/README.md: -------------------------------------------------------------------------------- 1 | Pages are usually used for normal pages or for listing items from a GraphQL collection. 2 | Add .vue files here to create pages. For example **About.vue** will be **site.com/about**. 3 | Learn more about pages: https://gridsome.org/docs/pages 4 | 5 | You can delete this file. -------------------------------------------------------------------------------- /src/pages/Showcase.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 27 | query { 28 | allBookEntry { 29 | edges { 30 | node{ 31 | id 32 | title 33 | authors { 34 | name 35 | }, 36 | cover { 37 | medium 38 | } 39 | byStatement 40 | publishDate 41 | } 42 | } 43 | } 44 | } 45 | 46 | 47 | 60 | 61 | 92 | -------------------------------------------------------------------------------- /src/templates/BookEntry.vue: -------------------------------------------------------------------------------- 1 | 52 | 53 | 54 | query Book ($id: String!){ 55 | bookEntry (id: $id) { 56 | id 57 | title 58 | authors { 59 | name 60 | }, 61 | cover { 62 | large 63 | } 64 | byStatement 65 | publishDate 66 | url 67 | subjectPlaces { 68 | name 69 | }, 70 | publishPlaces { 71 | name 72 | }, 73 | numberOfPages 74 | notes 75 | } 76 | } 77 | 78 | 79 | 86 | 87 | 106 | -------------------------------------------------------------------------------- /src/templates/README.md: -------------------------------------------------------------------------------- 1 | Templates for **GraphQL collections** should be added here. 2 | To create a template for a collection called `WordPressPost` 3 | create a file named `WordPressPost.vue` in this folder. 4 | 5 | Learn more: https://gridsome.org/docs/templates 6 | 7 | You can delete this file. -------------------------------------------------------------------------------- /static/README.md: -------------------------------------------------------------------------------- 1 | Add static files here. Files in this directory will be copied directly to `dist` folder during build. For example, /static/robots.txt will be located at https://yoursite.com/robots.txt. 2 | 3 | This file should be deleted. --------------------------------------------------------------------------------