├── .gitignore ├── README.md ├── gridsome.config.js ├── netlify.toml ├── package.json └── src ├── components └── Post.vue ├── favicon.png ├── layouts └── Default.vue ├── main.js ├── pages ├── About.vue └── Index.vue └── templates ├── WordPressCategory.vue ├── WordPressPost.vue └── WordPressPostTag.vue /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .cache 3 | .DS_Store 4 | src/.temp 5 | node_modules 6 | dist 7 | .env 8 | .env.* 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WordPress starter for Gridsome 2 | 3 | [](https://app.netlify.com/start/deploy?repository=https://github.com/gridsome/gridsome-starter-wordpress) 4 | 5 | ## Install 6 | 7 | `gridsome create my-gridsome-project wordpress` 8 | 9 | ## Guide 10 | 11 | Add your WordPress URL to the plugin options. 12 | 13 | ```js 14 | // gridsome.config.js 15 | 16 | module.exports = { 17 | plugins: [ 18 | { 19 | use: '@gridsome/source-wordpress', 20 | options: { 21 | baseUrl: 'YOUR_WEBSITE_URL', // required 22 | typeName: 'WordPress', // GraphQL schema name 23 | } 24 | } 25 | ], 26 | // Setup template routes for any WordPress collection 27 | templates: { 28 | WordPressPost: '/:year/:month/:day/:slug', 29 | WordPressTag: '/tag/:slug' 30 | }, 31 | } 32 | 33 | ``` 34 | 35 | See all [options](https://gridsome.org/plugins/@gridsome/source-wordpress). 36 | 37 | ## Included templates 38 | 39 | This starter includes basic templates for categories, tags and posts. 40 | -------------------------------------------------------------------------------- /gridsome.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | siteName: 'Gridsome', 3 | siteDescription: 'A WordPress starter for Gridsome', 4 | 5 | templates: { 6 | WordPressCategory: '/category/:slug', // adds a route for the "category" post type (Optional) 7 | WordPressPost: '/:year/:month/:day/:slug', // adds a route for the "post" post type (Optional) 8 | WordPressPostTag: '/tag/:slug' // adds a route for the "post_tag" post type (Optional) 9 | }, 10 | 11 | plugins: [ 12 | { 13 | use: '@gridsome/source-wordpress', 14 | options: { 15 | baseUrl: process.env.WORDPRESS_URL, // required 16 | typeName: 'WordPress', // GraphQL schema name (Optional) 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | publish = "dist" 3 | command = "gridsome build" 4 | 5 | [template.environment] 6 | WORDPRESS_URL = "Replace me with your Wordpress URL" 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "develop": "gridsome develop", 5 | "explore": "gridsome explore", 6 | "build": "gridsome build" 7 | }, 8 | "dependencies": { 9 | "@gridsome/source-wordpress": "^0.5.0", 10 | "gridsome": "^0.7.0" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/components/Post.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Read More 7 | 8 | 9 | 10 | 11 | 21 | -------------------------------------------------------------------------------- /src/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gridsome/gridsome-starter-wordpress/f9dfdfc3f6faddf8431f343ba8079411b5f18db6/src/favicon.png -------------------------------------------------------------------------------- /src/layouts/Default.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Gridsome 6 | 7 | 8 | Home 9 | About 10 | 11 | 12 | 13 | 14 | 15 | 16 | 55 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import DefaultLayout from '~/layouts/Default.vue' 2 | 3 | export default function (Vue) { 4 | Vue.component('Layout', DefaultLayout) 5 | } 6 | -------------------------------------------------------------------------------- /src/pages/About.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | About me 4 | Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error doloremque omnis animi, eligendi magni a voluptatum, vitae, consequuntur rerum illum odit fugit assumenda rem dolores inventore iste reprehenderit maxime! Iusto. 5 | 6 | 7 | 8 | 15 | -------------------------------------------------------------------------------- /src/pages/Index.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | Welcome to my blog :) 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | query Home ($page: Int) { 15 | allWordPressPost (page: $page, perPage: 10) @paginate { 16 | pageInfo { 17 | totalPages 18 | currentPage 19 | } 20 | edges { 21 | node { 22 | id 23 | title 24 | path 25 | excerpt 26 | } 27 | } 28 | } 29 | } 30 | 31 | 32 | 46 | -------------------------------------------------------------------------------- /src/templates/WordPressCategory.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | Category: {{ $page.wordPressCategory.title }} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | query WordPressCategory ($id: ID!, $page: Int) { 15 | wordPressCategory(id: $id) { 16 | title 17 | belongsTo(page: $page, perPage: 10) @paginate { 18 | pageInfo { 19 | totalPages 20 | currentPage 21 | } 22 | edges { 23 | node { 24 | ... on WordPressPost { 25 | id 26 | title 27 | path 28 | excerpt 29 | } 30 | } 31 | } 32 | } 33 | } 34 | } 35 | 36 | 37 | 53 | -------------------------------------------------------------------------------- /src/templates/WordPressPost.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | Posted in 13 | 14 | 15 | {{ category.title }} 16 | 17 | 18 | 19 | 20 | Tags 21 | 22 | 23 | {{ tag.title }} 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | query WordPressPost ($id: ID!) { 32 | wordPressPost(id: $id) { 33 | title 34 | content 35 | featuredMedia { 36 | sourceUrl 37 | altText 38 | mediaDetails { 39 | width 40 | } 41 | } 42 | categories { 43 | id 44 | title 45 | path 46 | } 47 | tags { 48 | id 49 | title 50 | path 51 | } 52 | } 53 | } 54 | 55 | 56 | 65 | 66 | 87 | -------------------------------------------------------------------------------- /src/templates/WordPressPostTag.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | Tag: {{ $page.wordPressPostTag.title }} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | query WordPressPostTag ($id: ID!, $page: Int) { 15 | wordPressPostTag(id: $id) { 16 | title 17 | belongsTo(page: $page, perPage: 10) @paginate { 18 | pageInfo { 19 | totalPages 20 | currentPage 21 | } 22 | edges { 23 | node { 24 | ... on WordPressPost { 25 | id 26 | title 27 | path 28 | excerpt 29 | } 30 | } 31 | } 32 | } 33 | } 34 | } 35 | 36 | 37 | 53 | --------------------------------------------------------------------------------
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error doloremque omnis animi, eligendi magni a voluptatum, vitae, consequuntur rerum illum odit fugit assumenda rem dolores inventore iste reprehenderit maxime! Iusto.