1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-15 17:45:31 +01:00
blog/gatsby-config.js

227 lines
6.3 KiB
JavaScript
Raw Normal View History

2018-11-21 23:39:09 +01:00
require('dotenv').config()
if (!process.env.GITHUB_TOKEN) {
// eslint-disable-next-line
console.warn(`
A GitHub token is required to build some parts of the blog.
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,
2018-11-17 16:14:37 +01:00
'gatsby-plugin-sharp',
'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: [
{
resolve: 'gatsby-remark-images',
options: {
2018-11-17 16:14:37 +01:00
maxWidth: 630,
2018-09-06 22:28:28 +02:00
quality: 80,
2018-12-01 23:54:45 +01:00
linkImagesToOriginal: true,
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
}
},
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
'gatsby-remark-smartypants',
{
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: {
colorTheme: 'Nord',
injectStyles: false,
extensions: [
{
identifier: 'arcticicestudio.nord-visual-studio-code',
version: '0.10.0'
}
],
languageAliases: {}
}
}
2018-07-11 17:56:13 +02:00
]
}
},
{
resolve: 'gatsby-plugin-sass',
options: {
2018-07-18 00:24:11 +02:00
includePaths: [`${__dirname}/node_modules`, `${__dirname}/src/styles`]
2018-07-11 17:56:13 +02:00
}
},
2018-09-24 22:28:07 +02:00
{
resolve: 'gatsby-plugin-svgr',
options: {
icon: true
}
},
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: {
title: node => node.frontmatter.title,
2018-10-14 00:16:15 +02:00
excerpt: node => node.excerpt,
2018-08-28 23:28:42 +02:00
tags: node => node.frontmatter.tags,
2018-11-18 16:41:37 +01:00
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',
2018-09-30 03:11:08 +02:00
siteUrl: `${siteConfig.siteUrl}`
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-06-11 01:34:11 +02:00
name: siteConfig.siteTitle.toLowerCase(),
short_name: 'mk',
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',
2018-09-27 21:14:22 +02:00
display: 'minimal-ui',
2019-06-11 01:34:11 +02:00
cache_busting_mode: 'name'
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 } }) => {
2019-04-13 22:52:58 +02:00
return allMarkdownRemark.edges.map(edge => {
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] },
limit: 20
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: {
2018-12-12 18:42:02 +01:00
exclude: ['/page/*', '/tags/*']
}
},
2019-10-03 19:18:01 +02:00
{
resolve: 'gatsby-plugin-use-dark-mode',
options: {
classNameDark: 'dark',
classNameLight: 'light',
minify: true
}
},
2018-09-30 03:11:08 +02:00
'gatsby-plugin-webpack-size',
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',
2019-10-02 13:35:50 +02:00
'gatsby-plugin-offline',
'gatsby-plugin-typescript'
2018-07-11 17:56:13 +02:00
]
}