1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-22 09:56:51 +01:00
blog/gatsby-config.ts

221 lines
6.2 KiB
TypeScript
Raw Normal View History

import type { GatsbyConfig } from 'gatsby'
2023-08-17 15:03:25 +02:00
import 'dotenv/config'
2018-08-30 17:23:55 +02:00
// required for gatsby-plugin-meta-redirect
import 'regenerator-runtime/runtime'
2023-01-29 22:58:19 +01:00
import siteConfig from './config'
import { feedContent } from './gatsby/feeds'
import sources from './gatsby/sources'
2018-08-30 17:23:55 +02:00
2022-11-20 01:06:56 +01:00
//import algolia from './gatsby/algolia'
const config: GatsbyConfig = {
graphqlTypegen: {
typesOutputPath: './src/@types/Gatsby.d.ts',
generateOnBuild: true
},
2018-07-11 17:56:13 +02:00
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',
2023-01-29 23:24:26 +01:00
parentSelector: { 'html.dark': 'Nord' }
2020-06-01 16:47:36 +02:00
},
2019-07-15 13:20:41 +02:00
injectStyles: false,
2023-04-01 00:48:48 +02:00
extensions: [
'nord-visual-studio-code',
`${__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: {
2023-08-17 13:43:32 +02:00
icon: true,
2019-11-15 22:10:53 +01:00
svgoConfig: {
2023-08-17 13:43:32 +02:00
plugins: [
{
name: 'preset-default',
params: { overrides: { removeViewBox: 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-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: [
{
serialize: ({ query }: { query: Queries.AllContentFeedQuery }) => {
return query.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,
2019-04-13 22:52:58 +02:00
description: edge.node.excerpt,
url: siteConfig.siteUrl + edge.node.fields?.slug,
categories: edge.node.frontmatter?.tags,
2019-04-13 22:52:58 +02:00
author: siteConfig.author.name,
guid: siteConfig.siteUrl + edge.node.fields?.slug,
2019-04-13 22:52:58 +02:00
custom_elements: [{ 'content:encoded': feedContent(edge) }]
})
})
2018-09-15 22:26:04 +02:00
},
query: `{
allMarkdownRemark(sort: {fields: {date: DESC}}, limit: 40) {
edges {
node {
html
fields {
slug
date
}
excerpt
frontmatter {
title
image {
childImageSharp {
resize(width: 940, quality: 85) {
src
}
}
}
}
}
}
2018-09-15 22:26:04 +02:00
}
}`,
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']
}
},
'gatsby-plugin-catch-links',
2018-08-30 17:23:55 +02:00
'gatsby-redirect-from',
2022-11-20 15:51:22 +01:00
'gatsby-plugin-meta-redirect'
2022-11-20 01:06:56 +01:00
// { ...algolia }
2018-07-11 17:56:13 +02:00
]
}
export default config