forked from kyma-project/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite Gatsby API from gatsby folder to TS (kyma-project#369)
- Loading branch information
1 parent
5988a69
commit a7d770e
Showing
52 changed files
with
1,419 additions
and
664 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,174 +1,3 @@ | ||
const siteMetadata = require("./config.json").siteMetadata; | ||
const { config } = require("./gatsby"); | ||
|
||
module.exports = { | ||
siteMetadata, | ||
plugins: [ | ||
"gatsby-plugin-react-helmet", | ||
{ | ||
resolve: "gatsby-plugin-styled-components", | ||
options: { | ||
ssr: false, | ||
displayName: true, | ||
}, | ||
}, | ||
"gatsby-plugin-lodash", | ||
"gatsby-plugin-typescript", | ||
{ | ||
resolve: "gatsby-source-filesystem", | ||
options: { | ||
name: "content", | ||
path: `${__dirname}/content/`, | ||
}, | ||
}, | ||
{ | ||
resolve: "gatsby-plugin-copy-files", | ||
options: { | ||
source: `${__dirname}/content`, | ||
destination: "/assets", | ||
extensions: ["jpeg", "jpg", "gif", "png", "svg", "json", "yaml", "yml"], | ||
// add regex possibility | ||
excludeDirs: ["i18n"], | ||
excludeFiles: [ | ||
"docs/versions.json", | ||
"docs.config.json", | ||
"manifest.yaml", | ||
"events.yaml", | ||
], | ||
}, | ||
}, | ||
{ | ||
resolve: "gatsby-plugin-anchor-behavior", | ||
options: { | ||
paths: { | ||
"/docs/": { | ||
defaultOffset: 16, | ||
mobileOffset: 74, | ||
}, | ||
"/roadmap/": { | ||
defaultOffset: 0, | ||
mobileOffset: 0, | ||
}, | ||
}, | ||
defaultOffset: 16, | ||
mobileOffset: 74, | ||
mobileOffsetInclude: ["/docs"], | ||
}, | ||
}, | ||
"gatsby-plugin-banner-slides-yml", | ||
"gatsby-plugin-early-adopters-yml", | ||
{ | ||
resolve: "gatsby-transformer-remark", | ||
options: { | ||
excerpt_separator: `<!-- overview -->`, | ||
}, | ||
}, | ||
{ | ||
resolve: "gatsby-plugin-manifest", | ||
options: { | ||
name: "Kyma", | ||
short_name: "Kyma", | ||
start_url: "/", | ||
background_color: "#fff", | ||
theme_color: "#0073e6", | ||
display: "standalone", | ||
icon: "static/android-chrome-512x512.png", | ||
}, | ||
}, | ||
{ | ||
resolve: `gatsby-plugin-gtag`, | ||
options: { | ||
trackingId: "UA-122665881-1", | ||
head: true, | ||
anonymize: true, | ||
}, | ||
}, | ||
`gatsby-plugin-sitemap`, | ||
`gatsby-plugin-netlify`, | ||
`gatsby-plugin-netlify-cache`, | ||
{ | ||
resolve: `gatsby-plugin-env-variables`, | ||
options: { | ||
whitelist: ["GOOGLE_CSE", "ALGOLIA_API_KEY", "ALGOLIA_INDEX_NAME"], | ||
}, | ||
}, | ||
{ | ||
resolve: `gatsby-plugin-feed`, | ||
options: { | ||
query: ` | ||
{ | ||
site { | ||
siteMetadata { | ||
title | ||
description | ||
siteUrl | ||
site_url: siteUrl | ||
} | ||
} | ||
} | ||
`, | ||
feeds: [ | ||
{ | ||
serialize: ({ query: { site, allMarkdownRemark } }) => { | ||
return allMarkdownRemark.edges | ||
.filter(arg => arg.node.fields.slug.startsWith("/blog/")) | ||
.map(edge => { | ||
const getAuthor = arg => { | ||
if ( | ||
arg.node.frontmatter.author && | ||
!!arg.node.frontmatter.author.name | ||
) { | ||
return arg.node.frontmatter.author.name; | ||
} | ||
return null; | ||
}; | ||
|
||
const host = site.siteMetadata.siteUrl; | ||
const link = `${ | ||
host.endsWith("/") ? host : host + "/" | ||
}${edge.node.fields.slug.slice(1)}`; | ||
|
||
return { | ||
...edge.node.frontmatter, | ||
date: edge.node.frontmatter.date, | ||
url: link, | ||
guid: link, | ||
author: getAuthor(edge), | ||
description: edge.node.excerpt, | ||
custom_elements: [{ "content:encoded": edge.node.html }], | ||
}; | ||
}); | ||
}, | ||
query: ` | ||
{ | ||
allMarkdownRemark(sort: {order: DESC, fields: [fields___date]}) { | ||
edges { | ||
node { | ||
excerpt | ||
html | ||
fields { | ||
slug | ||
date | ||
} | ||
frontmatter { | ||
title | ||
author { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
output: `${ | ||
siteMetadata.feedUrl.startsWith("/") | ||
? siteMetadata.feedUrl | ||
: "/" + siteMetadata.feedUrl | ||
}`, | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
pathPrefix: "/website", | ||
}; | ||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
exports.onCreateWebpackConfig = require("./gatsby/onCreateWebpackConfig"); | ||
exports.createPages = require("./gatsby/createPages"); | ||
exports.onCreateNode = require("./gatsby/onCreateNode"); | ||
exports.onCreatePage = require("./gatsby/onCreatePage"); | ||
const { | ||
onCreateWebpackConfig, | ||
createPages, | ||
onCreateNode, | ||
onCreatePage, | ||
} = require("./gatsby"); | ||
|
||
module.exports = { | ||
onCreateWebpackConfig, | ||
createPages, | ||
onCreateNode, | ||
onCreatePage, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { GatsbyConfig } from "gatsby"; | ||
import { siteMetadata } from "./sitemetadata"; | ||
import { plugins } from "./plugins"; | ||
|
||
export const config: GatsbyConfig = { | ||
siteMetadata: siteMetadata as Record<string, any>, | ||
plugins, | ||
pathPrefix: "/website", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { rssFeed } from "./rss-feed"; | ||
import { Plugins } from "./types"; | ||
|
||
export const plugins: Plugins = [ | ||
"gatsby-plugin-react-helmet", | ||
{ | ||
resolve: "gatsby-plugin-styled-components", | ||
options: { | ||
ssr: false, | ||
displayName: true, | ||
}, | ||
}, | ||
"gatsby-plugin-lodash", | ||
"gatsby-plugin-typescript", | ||
{ | ||
resolve: "gatsby-source-filesystem", | ||
options: { | ||
name: "content", | ||
path: `${__dirname}/../../content/`, | ||
}, | ||
}, | ||
{ | ||
resolve: "gatsby-plugin-copy-files", | ||
options: { | ||
source: `${__dirname}/../../content`, | ||
destination: "/assets", | ||
extensions: ["jpeg", "jpg", "gif", "png", "svg", "json", "yaml", "yml"], | ||
// add regex possibility | ||
excludeDirs: ["i18n"], | ||
excludeFiles: [ | ||
"docs/versions.json", | ||
"docs.config.json", | ||
"manifest.yaml", | ||
"events.yaml", | ||
], | ||
}, | ||
}, | ||
{ | ||
resolve: "gatsby-plugin-anchor-behavior", | ||
options: { | ||
paths: { | ||
"/docs/": { | ||
defaultOffset: 16, | ||
mobileOffset: 74, | ||
}, | ||
"/roadmap/": { | ||
defaultOffset: 0, | ||
mobileOffset: 0, | ||
}, | ||
}, | ||
defaultOffset: 16, | ||
mobileOffset: 74, | ||
mobileOffsetInclude: ["/docs"], | ||
}, | ||
}, | ||
"gatsby-plugin-banner-slides-yml", | ||
"gatsby-plugin-early-adopters-yml", | ||
{ | ||
resolve: "gatsby-transformer-remark", | ||
options: { | ||
excerpt_separator: `<!-- overview -->`, | ||
}, | ||
}, | ||
{ | ||
resolve: "gatsby-plugin-manifest", | ||
options: { | ||
name: "Kyma", | ||
short_name: "Kyma", | ||
start_url: "/", | ||
background_color: "#fff", | ||
theme_color: "#0073e6", | ||
display: "standalone", | ||
icon: "static/android-chrome-512x512.png", | ||
}, | ||
}, | ||
{ | ||
resolve: `gatsby-plugin-gtag`, | ||
options: { | ||
trackingId: "UA-122665881-1", | ||
head: true, | ||
anonymize: true, | ||
}, | ||
}, | ||
`gatsby-plugin-sitemap`, | ||
`gatsby-plugin-netlify`, | ||
`gatsby-plugin-netlify-cache`, | ||
{ | ||
resolve: `gatsby-plugin-env-variables`, | ||
options: { | ||
whitelist: ["GOOGLE_CSE", "ALGOLIA_API_KEY", "ALGOLIA_INDEX_NAME"], | ||
}, | ||
}, | ||
rssFeed, | ||
]; |
Oops, something went wrong.