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

239 lines
6.5 KiB
JavaScript
Raw Normal View History

2018-07-11 17:56:13 +02:00
const path = require('path')
2018-09-30 03:11:08 +02:00
const siteConfig = require('./config')
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-07-17 23:33:55 +02:00
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'posts',
path: path.join(__dirname, 'content', 'posts')
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'media',
path: path.join(__dirname, 'content', 'media')
}
},
2018-08-11 02:39:18 +02:00
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'images',
path: path.join(__dirname, 'src', 'images')
}
},
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-07-17 23:33:55 +02:00
maxWidth: 940,
2018-09-06 22:28:28 +02:00
quality: 80,
withWebp: true,
2018-07-17 23:33:55 +02:00
linkImagesToOriginal: false,
2018-07-20 15:23:57 +02: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: [
{ name: 'title', store: true, attributes: { boost: 20 } },
{ name: 'excerpt', attributes: { boost: 10 } },
2018-10-14 00:16:15 +02:00
{ name: 'tags', store: true, attributes: { boost: 5 } },
{ 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-10-14 00:16:15 +02:00
content: node => node.rawMarkdownBody
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 } }) => {
2018-09-25 01:08:08 +02:00
return allMarkdownRemark.edges.map(edge => ({
title: edge.node.frontmatter.title,
date: edge.node.fields.date,
description: feedContent(edge),
2018-10-01 22:43:38 +02:00
url: siteConfig.siteUrl + edge.node.fields.slug,
2018-09-25 01:08:08 +02:00
categories: edge.node.frontmatter.tags,
2018-10-01 22:43:38 +02:00
author: siteConfig.author.name,
guid: siteConfig.siteUrl + edge.node.fields.slug
2018-09-25 01:08:08 +02:00
}))
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 }
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: {
exclude: ['/page/*', '/tag/*']
}
},
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-sharp',
2018-09-07 13:08:01 +02:00
'gatsby-transformer-sharp',
'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-sitemap',
'gatsby-plugin-offline'
2018-07-11 17:56:13 +02:00
]
}
2018-09-15 22:26:04 +02:00
const feedContent = edge => {
const { image } = edge.node.frontmatter
2018-09-25 01:08:08 +02:00
const { html } = edge.node
const footer =
'<hr />This post was published on <a href="https://kremalicious.com">kremalicious.com</a>'
2018-09-15 22:26:04 +02:00
return image
2018-09-25 01:08:08 +02:00
? `<img src="${image.childImageSharp.resize.src}" /><br />${html}${footer}`
: `${html}${footer}`
2018-09-15 22:26:04 +02:00
}