Automatically create cover images for your blog posts
npm install gridsome-plugin-blog-cover
Ensure you have a Cloudinary account, @gridsome/source-filesystem
and @gridsome/transformer-remark
installed as well.
Add the code after registering @gridsome/source-filesystem
as a plugin.
plugins: [
//...
{
use: 'gridsome-plugin-blog-cover',
options: {
typeName: 'Post',
outputDir: './content/images',
domain: 'https://example.com',
coverField: 'cover_image',
cloud_name: 'YOUR_CLOUDINARY_CLOUD_NAME',
api_key: 'YOUR_CLOUDINARY_API_KEY',
api_secret: 'YOUR_CLOUDINARY_API_SECRET'
}
}
]
The collection name for your posts.
- expected value:
String
- default:
Post
The directory to generate the cover images in, this should be relative to your project's root directory
- expected value:
String
- default:
content/images/
The url of your blog site
- expected value:
String
- default:
https://awesomeblog.com
The field used for cover images
- expected value:
String
- default:
cover_image
Your cloudinary cloud name
- expected value:
String
Your cloudinary API key
- expected value:
String
Your cloudinary API secret
- expected value:
String
The url of your blog site favicon. The images dimensions should be at least 50x50
px
- expected value:
String
- default:
https://awesomeblog.com/favicon.png
The folder to use for all uploads on Cloudinary
- expected value:
String
- default:
blog_covers
Have a thin white border around the content
- expected value:
Boolean
- default:
true
Have a thin white border around the content
- expected value:
String
- default:
#ffffff
An array of Hex color codes to use for backgrounds
- expected value:
Array
- default:
['#30475e', '#381460', '#ba6b57', '#21243d', '#434e52']
A desired minimum height for the image
- expected value:
String
- default:
650px
A desired minmum width for the image
- expected value:
String
- default:
700px
<page-query>
query{
posts: allPost{
edges{
node{
id
title
cover_image # or your specified cover field
}
}
}
}
</page-query>