Skip to content

Commit

Permalink
Merge pull request #21 from sungik-choi/fix/config
Browse files Browse the repository at this point in the history
Fix & Refactor gatsby config file
  • Loading branch information
sungik-choi authored Jan 2, 2022
2 parents 965716a + a84f29b commit a34dfd9
Show file tree
Hide file tree
Showing 7 changed files with 1,579 additions and 194 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-undef */
module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["jsx-a11y", "@typescript-eslint", "react"],
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
290 changes: 183 additions & 107 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,128 +1,204 @@
const meta = require("./gatsby-meta-config")

module.exports = {
siteMetadata: {
title: meta.title,
description: meta.description,
author: meta.author,
siteUrl: meta.siteUrl,
lang: meta.lang,
utterances: {
repo: meta.utterances,
},
postTitle: "All",
menuLinks: [
{
link: "/",
name: "Home",
},
{
link: "/about/",
name: "About",
},
{
link: meta.links.github,
name: "Github",
},
],
plugins: [
"gatsby-plugin-robots-txt",
"gatsby-plugin-sitemap",
"gatsby-plugin-feed",
],
const siteMetadata = {
title: meta.title,
description: meta.description,
author: meta.author,
siteUrl: meta.siteUrl,
lang: meta.lang,
utterances: {
repo: meta.utterances,
},
plugins: [
postTitle: "All",
menuLinks: [
{
resolve: "gatsby-plugin-alias-imports",
options: {
alias: {
Src: "src",
Components: "src/components",
Constants: "src/constants",
Hooks: "src/hooks",
Images: "src/images",
Layouts: "src/layouts",
Pages: "src/pages",
Posts: "src/posts",
Stores: "src/stores",
Styles: "src/styles",
Templates: "src/templates",
Types: "src/types",
Utils: "src/utils",
},
extensions: ["js", "ts", "tsx"],
},
link: "/",
name: "Home",
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "src",
path: `${__dirname}/src`,
},
link: "/about/",
name: "About",
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "images",
path: `${__dirname}/src/images`,
},
link: meta.links.github,
name: "Github",
},
{
resolve: "gatsby-plugin-typography",
options: {
pathToConfigModule: "src/styles/typography",
],
}

const corePlugins = [
{
resolve: "gatsby-source-filesystem",
options: {
name: "src",
path: `${__dirname}/src`,
},
},
{
resolve: "gatsby-source-filesystem",
options: {
name: "images",
path: `${__dirname}/src/images`,
},
},
]

const devPlugins = [
{
resolve: "gatsby-plugin-alias-imports",
options: {
alias: {
Src: "src",
Components: "src/components",
Constants: "src/constants",
Hooks: "src/hooks",
Images: "src/images",
Layouts: "src/layouts",
Pages: "src/pages",
Posts: "src/posts",
Stores: "src/stores",
Styles: "src/styles",
Templates: "src/templates",
Types: "src/types",
Utils: "src/utils",
},
extensions: ["js", "ts", "tsx"],
},
{
resolve: "gatsby-transformer-remark",
options: {
plugins: [
"gatsby-remark-copy-linked-files",
`gatsby-remark-copy-linked-files`,
{
resolve: "gatsby-remark-vscode",
options: {
theme: {
default: "Github Light Theme",
parentSelector: {
"body[data-theme=dark]": "Dark Github",
},
},
{
resolve: "gatsby-plugin-typography",
options: {
pathToConfigModule: "src/styles/typography",
},
},
"gatsby-plugin-react-helmet",
"gatsby-plugin-typescript",
"gatsby-plugin-styled-components",
]

const imagePlugins = [
"gatsby-plugin-image",
"gatsby-plugin-sharp",
"gatsby-transformer-sharp",
]

const markdownPlugins = [
{
resolve: "gatsby-transformer-remark",
options: {
plugins: [
"gatsby-remark-copy-linked-files",
{
resolve: "gatsby-remark-vscode",
options: {
theme: {
default: "Github Light Theme",
parentSelector: {
"body[data-theme=dark]": "Dark Github",
},
extensions: ["vscode-theme-github-light", "dark-theme-github"],
},
extensions: ["vscode-theme-github-light", "dark-theme-github"],
},
{
resolve: "gatsby-remark-images",
options: {
linkImagesToOriginal: false,
},
},
{
resolve: "gatsby-remark-images",
options: {
linkImagesToOriginal: false,
},
],
},
},
],
},
{
resolve: "gatsby-plugin-manifest",
options: {
name: meta.title,
short_name: meta.title,
description: meta.description,
lang: meta.lang,
start_url: "/",
background_color: "#ffffff",
theme_color: "#ffffff",
display: "standalone",
icon: meta.favicon,
icon_options: {
purpose: "any maskable",
},
]

const searchPlugins = [
"gatsby-plugin-sitemap",
"gatsby-plugin-robots-txt",
{
resolve: `gatsby-plugin-feed`,
options: {
query: `
{
site {
siteMetadata {
title
description
siteUrl
site_url: siteUrl
}
}
}
`,
feeds: [
{
serialize: ({ query: { site, allMarkdownRemark } }) => {
return allMarkdownRemark.edges.map(edge => {
return Object.assign({}, edge.node.frontmatter, {
description: edge.node.excerpt,
date: edge.node.frontmatter.date,
url: site.siteMetadata.siteUrl + edge.node.fields.slug,
guid: site.siteMetadata.siteUrl + edge.node.fields.slug,
custom_elements: [{ "content:encoded": edge.node.html }],
})
})
},
query: `
{
allMarkdownRemark(
filter: { fileAbsolutePath: { regex: "/(posts/blog)/" } }
sort: { order: DESC, fields: [frontmatter___date] },
) {
edges {
node {
excerpt
html
fields { slug }
frontmatter {
title
date
}
}
}
}
}
`,
output: "/rss.xml",
title: `${meta.title}'s RSS Feed`,
},
],
},
},
]

const pwaPlugins = [
{
resolve: "gatsby-plugin-manifest",
options: {
name: meta.title,
short_name: meta.title,
description: meta.description,
lang: meta.lang,
start_url: "/",
background_color: "#ffffff",
theme_color: "#ffffff",
display: "standalone",
icon: meta.favicon,
icon_options: {
purpose: "any maskable",
},
},
"gatsby-plugin-image",
"gatsby-plugin-sharp",
"gatsby-transformer-sharp",
"gatsby-plugin-styled-components",
"gatsby-plugin-offline",
"gatsby-plugin-react-helmet",
"gatsby-plugin-typescript",
},
"gatsby-plugin-offline",
]

module.exports = {
siteMetadata,
plugins: [
...corePlugins,
...devPlugins,
...imagePlugins,
...markdownPlugins,
...searchPlugins,
...pwaPlugins,
],
}
Loading

0 comments on commit a34dfd9

Please sign in to comment.