1
0
Fork 0
blog/gatsby-config.js

226 lines
6.2 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,
withWebp: true,
2018-12-01 23:54:45 +01:00
linkImagesToOriginal: true,
2018-11-17 16:14:37 +01:00
sizeByPixelDensity: true,
2018-07-18 00:24:11 +02:00
showCaptions: true,
2018-09-06 22:28:28 +02:00
backgroundColor: '#e7eef4'
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'
}
},
{
resolve: 'gatsby-remark-highlights',
options: {
codeWrap: {
className: 'nord'
}
}
},
2018-07-17 23:33:55 +02:00
'gatsby-remark-smartypants',
'gatsby-remark-autolink-headers'
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
{
resolve: 'gatsby-plugin-favicon',
options: {
logo: './src/images/apple-touch-icon.png',
// WebApp Manifest Configuration
2018-09-30 03:11:08 +02:00
appName: siteConfig.siteTitle.toLowerCase(),
appDescription: siteConfig.siteDescription,
developerName: siteConfig.author.name,
developerURL: siteConfig.author.uri,
2018-09-27 21:14:22 +02:00
dir: 'auto',
lang: 'en-US',
2018-09-30 03:11:08 +02:00
background: siteConfig.backgroundColor,
theme_color: siteConfig.themeColor,
2018-09-27 21:14:22 +02:00
display: 'minimal-ui',
orientation: 'any',
start_url: '/?homescreen=1',
version: '1.0',
icons: {
android: true,
appleIcon: true,
appleStartup: true,
coast: false,
favicons: true,
firefox: true,
opengraph: false,
twitter: false,
yandex: false,
windows: false
}
}
},
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
}
}
}
}
}
}
}
}
`,
output: '/feed.xml'
}
]
}
},
{
resolve: 'gatsby-plugin-sitemap',
options: {
2018-12-12 18:42:02 +01:00
exclude: ['/page/*', '/tags/*']
}
},
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',
'gatsby-plugin-offline'
2018-07-11 17:56:13 +02:00
]
}