1
0
Fork 0
blog/gatsby-config.js

231 lines
6.5 KiB
JavaScript
Raw Normal View History

2018-11-21 23:39:09 +01:00
require('dotenv').config()
2019-11-17 13:11:42 +01:00
if (!process.env.GATSBY_GITHUB_TOKEN) {
2018-11-21 23:39:09 +01:00
// eslint-disable-next-line
console.warn(`
2019-11-17 13:11:42 +01:00
A GitHub token as GATSBY_GITHUB_TOKEN is required to build some parts of the blog.
2018-11-21 23:39:09 +01:00
Check the README https://github.com/kremalicious/blog#-development.
`)
}
2018-09-30 03:11:08 +02:00
const siteConfig = require('./config')
2018-11-22 00:01:38 +01:00
const sources = require('./gatsby/sources')
2019-04-13 22:52:58 +02:00
const { feedContent } = require('./gatsby/feeds')
2018-07-11 17:56:13 +02:00
2018-08-30 17:23:55 +02:00
// required for gatsby-plugin-meta-redirect
require('regenerator-runtime/runtime')
2018-07-11 17:56:13 +02:00
module.exports = {
siteMetadata: {
2018-09-30 03:11:08 +02:00
...siteConfig
2018-07-11 17:56:13 +02:00
},
plugins: [
2018-11-22 00:01:38 +01:00
...sources,
2021-03-06 02:58:10 +01:00
'gatsby-plugin-image',
2019-11-16 00:59:10 +01:00
{
resolve: 'gatsby-plugin-sharp',
options: {
stripMetadata: false,
2021-12-02 19:23:17 +01:00
defaults: {
quality: 85
}
2019-11-16 00:59:10 +01:00
}
},
2018-11-17 16:14:37 +01:00
'gatsby-transformer-sharp',
2018-07-11 17:56:13 +02:00
{
resolve: 'gatsby-transformer-remark',
options: {
2018-07-19 23:04:41 +02:00
excerpt_separator: '<!-- more -->',
2018-07-11 17:56:13 +02:00
plugins: [
2021-06-11 22:02:15 +02:00
'gatsby-remark-smartypants',
2018-07-11 17:56:13 +02:00
{
resolve: 'gatsby-remark-images',
options: {
2020-05-10 22:57:00 +02:00
maxWidth: 666,
2018-09-06 22:28:28 +02:00
quality: 80,
2020-01-01 21:23:46 +01:00
linkImagesToOriginal: false,
2018-07-18 00:24:11 +02:00
showCaptions: true,
2019-10-15 01:47:34 +02:00
backgroundColor: 'none',
2019-10-03 19:18:01 +02:00
disableBgImageOnAlpha: true
2018-07-11 17:56:13 +02:00
}
},
2020-01-01 21:23:46 +01:00
{
resolve: 'gatsby-remark-images-medium-zoom',
options: {
background: '#e7eef4'
}
},
2018-07-19 23:04:41 +02:00
{
resolve: 'gatsby-remark-copy-linked-files',
options: {
destinationDir: 'media'
}
},
{
2019-07-15 13:20:41 +02:00
resolve: 'gatsby-remark-autolink-headers',
options: {
2019-07-15 14:40:40 +02:00
icon: '<span>#</span>'
}
},
2019-07-15 13:20:41 +02:00
{
// https://github.com/andrewbranch/gatsby-remark-vscode
resolve: 'gatsby-remark-vscode',
options: {
2020-06-01 16:47:36 +02:00
theme: {
default: 'Polar',
parentSelector: { 'body.dark': 'Nord' }
},
2019-07-15 13:20:41 +02:00
injectStyles: false,
2020-06-01 16:47:36 +02:00
extensions: [
'nord-visual-studio-code',
2020-06-01 16:47:36 +02:00
`${__dirname}/vendor/polar-0.0.6.vsix`
],
2019-07-15 13:20:41 +02:00
languageAliases: {}
}
}
2018-07-11 17:56:13 +02:00
]
}
},
2018-09-24 22:28:07 +02:00
{
resolve: 'gatsby-plugin-svgr',
options: {
2019-11-15 22:10:53 +01:00
icon: false,
svgoConfig: {
2022-05-08 21:35:38 +02:00
plugins: [{ name: 'removeViewBox', active: false }]
2019-11-15 22:10:53 +01:00
}
2018-09-24 22:28:07 +02:00
}
},
2018-08-28 23:28:42 +02:00
{
resolve: 'gatsby-plugin-lunr',
options: {
languages: [
{
// ISO 639-1 language codes. See https://lunrjs.com/guides/language_support.html for details
name: 'en'
}
],
// Fields to index. If store === true value will be stored in index file.
// Attributes for custom indexing logic. See https://lunrjs.com/docs/lunr.Builder.html for details
fields: [
2018-11-18 19:34:55 +01:00
{ name: 'title', attributes: { boost: 20 } },
2018-11-18 16:41:37 +01:00
{ name: 'tags', attributes: { boost: 15 } },
2018-08-28 23:28:42 +02:00
{ name: 'excerpt', attributes: { boost: 10 } },
2018-11-18 19:34:55 +01:00
{ name: 'slug', store: true },
2018-10-14 00:16:15 +02:00
{ name: 'content' }
2018-08-28 23:28:42 +02:00
],
// How to resolve each field's value for a supported node type
resolvers: {
// For any node of type MarkdownRemark, list how to resolve the fields' values
MarkdownRemark: {
2020-04-12 11:15:42 +02:00
title: (node) => node.frontmatter.title,
excerpt: (node) => node.excerpt,
tags: (node) => node.frontmatter.tags,
content: (node) => node.rawMarkdownBody,
slug: (node) => node.fields.slug
2018-08-28 23:28:42 +02:00
}
}
}
},
2018-09-12 21:50:54 +02:00
{
resolve: 'gatsby-plugin-matomo',
options: {
siteId: '1',
matomoUrl: 'https://analytics.kremalicious.com',
2020-04-12 11:15:42 +02:00
siteUrl: `${siteConfig.siteUrl}`,
trackLoad: false
2018-09-12 21:50:54 +02:00
}
},
2018-09-27 21:14:22 +02:00
{
2019-06-11 01:34:11 +02:00
resolve: 'gatsby-plugin-manifest',
2018-09-27 21:14:22 +02:00
options: {
2019-11-09 18:13:13 +01:00
name: siteConfig.siteTitle,
2019-06-11 01:34:11 +02:00
start_url: '/',
background_color: siteConfig.backgroundColor,
2018-09-30 03:11:08 +02:00
theme_color: siteConfig.themeColor,
2019-06-11 01:34:11 +02:00
icon: 'src/images/apple-touch-icon.png',
2019-11-09 18:13:13 +01:00
display: 'standalone',
2019-11-09 19:20:39 +01:00
cache_busting_mode: 'name',
theme_color_in_head: false // dynamically set in ThemeSwitch
2018-09-27 21:14:22 +02:00
}
},
2018-09-15 22:26:04 +02:00
{
resolve: 'gatsby-plugin-feed',
options: {
query: `
{
site {
siteMetadata {
2018-10-01 22:43:38 +02:00
siteTitle
siteDescription
2018-09-15 22:26:04 +02:00
siteUrl
2018-10-01 22:43:38 +02:00
title: siteTitle
description: siteDescription
2018-09-30 03:11:08 +02:00
site_url: siteUrl
2018-09-15 22:26:04 +02:00
}
}
}
`,
feeds: [
{
2018-10-01 22:43:38 +02:00
serialize: ({ query: { allMarkdownRemark } }) => {
2020-04-12 11:15:42 +02:00
return allMarkdownRemark.edges.map((edge) => {
2019-04-13 22:52:58 +02:00
return Object.assign({}, edge.node.frontmatter, {
title: edge.node.frontmatter.title,
date: edge.node.fields.date,
description: edge.node.excerpt,
url: siteConfig.siteUrl + edge.node.fields.slug,
categories: edge.node.frontmatter.tags,
author: siteConfig.author.name,
guid: siteConfig.siteUrl + edge.node.fields.slug,
custom_elements: [{ 'content:encoded': feedContent(edge) }]
})
})
2018-09-15 22:26:04 +02:00
},
query: `
{
allMarkdownRemark(
2018-09-25 01:08:08 +02:00
sort: { order: DESC, fields: [fields___date] },
2019-11-23 23:00:12 +01:00
limit: 40
2018-09-15 22:26:04 +02:00
) {
edges {
node {
html
fields { slug, date }
2019-04-13 22:52:58 +02:00
excerpt
2018-09-15 22:26:04 +02:00
frontmatter {
title
image {
childImageSharp {
2018-09-25 01:08:08 +02:00
resize(width: 940, quality: 85) {
2018-09-15 22:26:04 +02:00
src
}
}
}
}
}
}
}
}
`,
2019-10-02 21:59:43 +02:00
output: '/feed.xml',
title: siteConfig.siteTitle
2018-09-15 22:26:04 +02:00
}
]
}
},
{
resolve: 'gatsby-plugin-sitemap',
options: {
2021-05-23 13:53:34 +02:00
excludes: ['/archive', '/archive/**/*', '/thanks', '/tags']
}
},
2018-07-17 23:33:55 +02:00
'gatsby-plugin-react-helmet',
'gatsby-plugin-catch-links',
2018-08-30 17:23:55 +02:00
'gatsby-redirect-from',
2018-09-27 21:14:22 +02:00
'gatsby-plugin-meta-redirect',
'gatsby-plugin-offline'
2018-07-11 17:56:13 +02:00
]
}