This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Rewrite Gatsby API from gatsby folder to TS #369
Merged
magicmatatjahu
merged 9 commits into
kyma-project:master
from
magicmatatjahu:restructuring
Jul 19, 2019
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2e0eb51
Rewrite gatsby-node to typescript
magicmatatjahu 4bcc64d
Move gatsby-config to gatsby folder
magicmatatjahu 716a0b8
Fix typo
magicmatatjahu a4e1ea7
Fix typo issue with font-awesome
magicmatatjahu 730b1a1
After review
magicmatatjahu 29f9e4e
Fix type
magicmatatjahu 805db74
Fix bugs in feed plugin resolver
magicmatatjahu 39c0b8d
Niech ci Mateusz już będzie...
magicmatatjahu c43443d
Lol znowu
magicmatatjahu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract this to const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use it in one place, so extracting is unnecessary.