forked from getsentry/develop
-
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.
feat: Upgrade core docs tech from sentry-docs
- Move to typescript - Update directory structure - Update code tabs plugin - Pull in various common components
- Loading branch information
Showing
58 changed files
with
2,478 additions
and
986 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,6 +1,12 @@ | ||
import React from "react"; | ||
import PageContext from "~src/components/pageContext"; | ||
|
||
export const wrapPageElement = ({ element, props: { pageContext } }) => ( | ||
<PageContext.Provider value={pageContext}>{element}</PageContext.Provider> | ||
); | ||
|
||
// Disable prefetching altogether so our bw is not destroyed. | ||
// If this turns out to hurt performance significantly, we can | ||
// try out https://www.npmjs.com/package/gatsby-plugin-guess-js | ||
// with data from the prior 1-2 weeks. | ||
export const disableCorePrefetching = () => true; | ||
|
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,7 @@ | ||
// const path = require("path"); | ||
require("ts-node").register({ | ||
files: true, // to that TS node hooks have access to local typings too | ||
}); | ||
|
||
const activeEnv = | ||
process.env.GATSBY_ENV || process.env.NODE_ENV || "development"; | ||
|
||
|
@@ -8,134 +11,11 @@ require("dotenv").config({ | |
path: `.env.${activeEnv}`, | ||
}); | ||
|
||
const queries = require("./src/utils/algolia"); | ||
|
||
const getPlugins = () => { | ||
const plugins = [ | ||
{ | ||
resolve: "@sentry/gatsby", | ||
options: { | ||
dsn: | ||
process.env.SENTRY_DSN || | ||
"https://[email protected]/5266138", | ||
tracesSampleRate: activeEnv === "development" ? 0 : 1, | ||
}, | ||
}, | ||
"gatsby-plugin-sass", | ||
"gatsby-plugin-sharp", | ||
"gatsby-plugin-zeit-now", | ||
{ | ||
resolve: "gatsby-plugin-google-gtag", | ||
options: { | ||
// You can add multiple tracking ids and a pageview event will be fired for all of them. | ||
trackingIds: [ | ||
"UA-30327640-1", // Sentry | ||
], | ||
// This object gets passed directly to the gtag config command | ||
// This config will be shared across all trackingIds | ||
gtagConfig: { | ||
anonymize_ip: true, | ||
cookie_expires: 0, | ||
}, | ||
}, | ||
}, | ||
{ | ||
resolve: "gatsby-plugin-mdx", | ||
options: { | ||
remarkPlugins: [require("remark-deflist")], | ||
gatsbyRemarkPlugins: [ | ||
{ | ||
resolve: `gatsby-remark-copy-linked-files`, | ||
}, | ||
{ | ||
resolve: `gatsby-remark-autolink-headers`, | ||
options: { | ||
className: "anchor", | ||
icon: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10.879 6.05L15 1.93A5.001 5.001 0 0 1 22.071 9l-4.121 4.121a1 1 0 0 1-1.414-1.414l4.12-4.121a3 3 0 1 0-4.242-4.243l-4.121 4.121a1 1 0 1 1-1.414-1.414zm2.242 11.9L9 22.07A5 5 0 1 1 1.929 15l4.121-4.121a1 1 0 0 1 1.414 1.414l-4.12 4.121a3 3 0 1 0 4.242 4.243l4.121-4.121a1 1 0 1 1 1.414 1.414zm-8.364-.122l13.071-13.07a1 1 0 0 1 1.415 1.414L6.172 19.242a1 1 0 1 1-1.415-1.414z" fill="currentColor"></path></svg>`, | ||
enableCustomId: true, | ||
}, | ||
}, | ||
{ | ||
resolve: `gatsby-remark-images`, | ||
options: { | ||
maxWidth: 1200, | ||
linkImagesToOriginal: false, | ||
}, | ||
}, | ||
{ | ||
resolve: "gatsby-remark-mermaid", | ||
}, | ||
{ | ||
resolve: require.resolve("./plugins/gatsby-plugin-code-tabs"), | ||
}, | ||
{ | ||
resolve: require.resolve("./plugins/gatsby-plugin-include"), | ||
}, | ||
{ | ||
resolve: "gatsby-remark-prismjs", | ||
options: { | ||
noInlineHighlight: true, | ||
}, | ||
}, | ||
{ | ||
resolve: `gatsby-remark-check-links`, | ||
}, | ||
], | ||
}, | ||
}, | ||
"gatsby-plugin-react-helmet", | ||
{ | ||
resolve: `gatsby-source-filesystem`, | ||
options: { | ||
name: `images`, | ||
path: `${__dirname}/src/images`, | ||
}, | ||
}, | ||
{ | ||
resolve: `gatsby-source-filesystem`, | ||
options: { | ||
name: `docs`, | ||
path: `${__dirname}/src/docs`, | ||
}, | ||
}, | ||
{ | ||
resolve: `gatsby-source-filesystem`, | ||
options: { | ||
name: `pages`, | ||
path: `${__dirname}/src/pages`, | ||
}, | ||
}, | ||
{ | ||
resolve: require.resolve("./plugins/gatsby-plugin-jsonschema"), | ||
}, | ||
// this (optional) plugin enables Progressive Web App + Offline functionality | ||
// To learn more, visit: https://gatsby.app/offline | ||
// 'gatsby-plugin-offline', | ||
]; | ||
if (process.env.ALGOLIA_INDEX === "1") { | ||
plugins.push({ | ||
resolve: `gatsby-plugin-algolia`, | ||
options: { | ||
appId: process.env.GATSBY_ALGOLIA_APP_ID, | ||
apiKey: process.env.ALGOLIA_ADMIN_KEY, | ||
queries, | ||
chunkSize: 10000, // default: 1000 | ||
enablePartialUpdates: true, | ||
matchFields: ["text", "section", "title", "url", "keywords"], | ||
}, | ||
}); | ||
} | ||
return plugins; | ||
}; | ||
if ( | ||
process.env.VERCEL_GITHUB_COMMIT_REF === "master" && | ||
process.env.ALGOLIA_ADMIN_KEY | ||
) { | ||
process.env.ALGOLIA_INDEX = "1"; | ||
} | ||
|
||
module.exports = { | ||
// pathPrefix: `/develop`, | ||
siteMetadata: { | ||
title: "Sentry Developer Documentation", | ||
homeUrl: "https://sentry.io", | ||
sitePath: "develop.sentry.dev", | ||
description: "Documentation for contributing to the Sentry project", | ||
author: "@getsentry", | ||
}, | ||
plugins: getPlugins(), | ||
}; | ||
module.exports = require("./src/gatsby/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,77 +1,4 @@ | ||
const { createFilePath } = require("gatsby-source-filesystem"); | ||
|
||
exports.onCreateNode = ({ node, actions, getNode }) => { | ||
const { createNodeField } = actions; | ||
if ( | ||
node.internal.type === "Mdx" && | ||
(!node.parent || | ||
getNode(node.parent).internal.type !== "JsonSchemaMarkdown") | ||
) { | ||
const value = createFilePath({ node, getNode }); | ||
createNodeField({ | ||
name: "slug", | ||
node, | ||
value, | ||
}); | ||
} | ||
}; | ||
|
||
exports.createPages = async function({ actions, graphql }) { | ||
const { data, errors } = await graphql(` | ||
query { | ||
allFile { | ||
nodes { | ||
id | ||
childMdx { | ||
fields { | ||
slug | ||
} | ||
frontmatter { | ||
title | ||
sidebar_order | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`); | ||
|
||
if (errors) { | ||
reporter.panicOnBuild('🚨 ERROR: Loading "createPages" query'); | ||
} | ||
const component = require.resolve(`./src/components/layout.js`); | ||
data.allFile.nodes.forEach(node => { | ||
if (node.childMdx && node.childMdx.fields) { | ||
const child = node.childMdx; | ||
actions.createPage({ | ||
path: child.fields.slug, | ||
component, | ||
context: { | ||
id: node.id, | ||
title: child.frontmatter.title, | ||
sidebar_order: child.frontmatter.sidebar_order, | ||
sidebar_title: | ||
child.frontmatter.sidebar_title || child.frontmatter.title, | ||
}, | ||
}); | ||
} | ||
}); | ||
}; | ||
|
||
exports.createSchemaCustomization = ({ actions: { createTypes } }) => { | ||
const typeDefs = ` | ||
type Mdx implements Node { | ||
frontmatter: MdxFrontmatter | ||
} | ||
type MdxFrontmatter { | ||
title: String | ||
sidebar_order: Int | ||
sidebar_title: String | ||
keywords: [String] | ||
description: String | ||
} | ||
`; | ||
|
||
createTypes(typeDefs); | ||
}; | ||
exports.onCreateNode = require("./src/gatsby/onCreateNode").default; | ||
exports.onCreateWebpackConfig = require("./src/gatsby/onCreateWebpackConfig").default; | ||
exports.createPages = require("./src/gatsby/createPages").default; | ||
exports.createSchemaCustomization = require("./src/gatsby/createSchemaCustomization").default; |
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,6 @@ | ||
import React from "react"; | ||
import PageContext from "~src/components/pageContext"; | ||
|
||
export const wrapPageElement = ({ element, props: { pageContext } }) => ( | ||
<PageContext.Provider value={pageContext}>{element}</PageContext.Provider> | ||
); |
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
This file was deleted.
Oops, something went wrong.
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,41 @@ | ||
import React from "react"; | ||
|
||
type Props = { | ||
title?: string; | ||
level?: string; | ||
deepLink?: string; | ||
dismiss?: boolean; | ||
children?: any; | ||
}; | ||
|
||
export default ({ | ||
title, | ||
children, | ||
level, | ||
deepLink, | ||
dismiss = false, | ||
}: Props): JSX.Element => { | ||
let className = "alert"; | ||
if (level) { | ||
className += ` alert-${level}`; | ||
} | ||
if (children.props && typeof children.props.children === "string") { | ||
className += " markdown-text-only"; | ||
} | ||
return ( | ||
<div className={className} role="alert" id={deepLink}> | ||
{dismiss && ( | ||
<button | ||
type="button" | ||
className="close" | ||
data-dismiss="alert" | ||
aria-label="Close" | ||
> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
)} | ||
{title && <h5 className="no_toc">{title}</h5>} | ||
<div className="alert-body content-flush-bottom">{children}</div> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.