Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
feat: move i/o frontend code
Browse files Browse the repository at this point in the history
  • Loading branch information
tabathadelane authored and aswanson-nr committed Jan 24, 2022
1 parent 566061e commit a55931f
Show file tree
Hide file tree
Showing 76 changed files with 6,105 additions and 157 deletions.
166 changes: 164 additions & 2 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,143 @@
const quote = (str) => `"${str}"`;
const resolveQuickstartSlug = require("./src/utils/resolveQuickstartSlug");

module.exports = {
flags: {
DEV_SSR: true,
PRESERVE_WEBPACK_CACHE: true,
PRESERVE_FILE_DOWNLOAD_CACHE: true,
},
siteMetadata: {
siteUrl: `https://www.yourdomain.tld`,
title: "New Relic Developers",
titleTemplate: "%s | New Relic Developers",
description:
"Do more on our platform and make New Relic your own with APIs, SDKs, code snippets, tutorials, and more developer tools.",
author: "New Relic",
repository: "https://github.com/newrelic/developer-website",
siteUrl: "https://developer.newrelic.com",
branch: "develop",
},
plugins: [
"gatsby-plugin-sharp",
{
resolve: "@newrelic/gatsby-theme-newrelic",
options: {
oneTrustID: "77dd4d78-49db-4057-81ea-4bc325d6ecdd",
forceTrailingSlashes: true,
layout: {
contentPadding: "2rem",
maxWidth: "1700px",
component: require.resolve("./src/layouts"),
mobileBreakpoint: "760px",
},
prism: {
languages: ["yaml", "sass", "scss", "java"],
},
relatedResources: {
swiftype: {
resultsPath: `${__dirname}/src/data/related-pages.json`,
refetch: Boolean(process.env.BUILD_RELATED_CONTENT),
engineKey: "Ad9HfGjDw4GRkcmJjUut",
limit: 5,
getSlug: ({ node }) => {
if (node.internal.type === "Mdx") {
return node.fields.slug;
} else if (node.internal.type === "Quickstarts") {
return resolveQuickstartSlug(node.name, node.id);
}
},
getParams: ({ node }) => {
let tags = [];
let title = "";
if (node.frontmatter) {
tags = node.frontmatter.tags;
title = node.frontmatter.title;
} else {
tags = node.keywords;
title = node.title;
}
return {
q: tags ? tags.map(quote).join(" OR ") : title,
search_fields: {
page: [
"tags^10",
"quick_start_name^8",
"body^5",
"title^1.5",
"*",
],
},
filters: {
page: {
type: ["docs", "developer", "opensource", "quickstarts"],
document_type: [
"!views_page_menu",
"!term_page_api_menu",
"!term_page_landing_page",
],
},
},
};
},
filter: ({ node }) =>
node.frontmatter?.template === "GuideTemplate" ||
node.internal.type === "Quickstarts",
},
},
newrelic: {
configs: {
production: {
instrumentationType: "proAndSPA",
accountId: "10956800",
trustKey: "1",
agentID: "30712246",
licenseKey: "NRJS-649173eb1a7b28cd6ab",
applicationID: "30712246",
beacon: "staging-bam-cell.nr-data.net",
errorBeacon: "staging-bam-cell.nr-data.net",
},
staging: {
instrumentationType: "proAndSPA",
accountId: "10956800",
trustKey: "1",
agentID: "30712246",
licenseKey: "NRJS-649173eb1a7b28cd6ab",
applicationID: "30712246",
beacon: "staging-bam-cell.nr-data.net",
errorBeacon: "staging-bam-cell.nr-data.net",
},
},
},
tessen: {
tessenVersion: "1.14.0",
product: "DEV",
subproduct: "TDEV",
segmentWriteKey: "Ako0hclX8WGHwl9rm4n5uxLtT4wgEtuU",
trackPageViews: true,
pageView: {
eventName: "pageView",
category: "DocPageView",
getProperties: ({ location, env }) => ({
path: location.pathname,
env: env === "production" ? "prod" : env,
}),
},
},
},
},
"gatsby-plugin-sass",
{
resolve: "gatsby-plugin-manifest",
options: {
name: "gatsby-starter-default",
short_name: "starter",
start_url: "/",
background_color: "#663399",
theme_color: "#663399",
display: "minimal-ui",
icon: "src/images/favicon.png",
},
},
{
resolve: "gatsby-source-filesystem",
options: {
Expand All @@ -20,6 +155,34 @@ module.exports = {
typeName: "Quickstarts",
},
},
// "gatsby-remark-images",
// "gatsby-transformer-remark",
{
resolve: "gatsby-plugin-mdx",
options: {
// gatsbyRemarkPlugins: [
// {
// resolve: "gatsby-remark-images",
// options: {
// maxHeight: 400,
// maxWidth: 1200,
// fit: "inside",
// linkImagesToOriginal: false,
// },
// },
// {
// resolve: `gatsby-remark-autolink-headers`,
// options: {
// icon:
// '<svg xmlns="http://www.w3.org/2000/svg" focusable="false" width="1rem" height="1rem" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg>',
// },
// },
// ],
},
},

"gatsby-plugin-meta-redirect",
"gatsby-plugin-use-query-params",
{
resolve: "gatsby-plugin-gatsby-cloud",
options: {
Expand All @@ -28,4 +191,3 @@ module.exports = {
},
],
};

81 changes: 81 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
const path = require(`path`);
const resolveQuickstartSlug = require("./src/utils/resolveQuickstartSlug.js");

exports.createPages = async ({ actions, graphql, reporter }) => {
const { createPage } = actions;

const result = await graphql(`
query {
allQuickstarts {
edges {
node {
fields {
slug
}
id
}
}
}
}
`);

// Handle errors
if (result.errors) {
reporter.panicOnBuild(`Error while running GraphQL query.`);
return;
}
const { allQuickstarts } = result.data;

allQuickstarts.edges.forEach(({ node }) => {
const {
fields: { slug },
id,
} = node;

createPage({
path: path.join(slug, "/"),
component: path.resolve("./src/templates/QuickstartDetails.js"),
context: {
id,
layout: "QuickStartLayout",
},
});
});
};

exports.onCreatePage = async ({ page, actions }) => {
const { createPage, deletePage } = actions;
const oldPage = { ...page };

if (page.path === "/instant-observability/") {
page.context.layout = "QuickStartLayout";
}
deletePage(oldPage);
createPage(page);
};

exports.onCreateNode = ({ node, actions }) => {
const { createNodeField } = actions;

if (node.internal.type === "Quickstarts") {
createNodeField({
node,
name: "slug",
value: `${resolveQuickstartSlug(node.name, node.id)}`,
});
}
};

exports.onCreateWebpackConfig = ({ actions, plugins }) => {
actions.setWebpackConfig({
// The `debug` library is causing issues when building the site by including
// invalid JS. This ensures the module resolves to the browser-capatible
// source instead of the node source. See the following issue for this
// recommendation:
// https://github.com/escaladesports/legacy-gatsby-plugin-prefetch-google-fonts/issues/18
plugins: [plugins.normalModuleReplacement(/^\.\/node\.js/, "./browser.js")],
externals: {
tessen: "Tessen",
},
});
};
23 changes: 22 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,37 @@
"dependencies": {
"@emotion/react": "^11.1.5",
"@emotion/styled": "^11.3.0",
"@mdx-js/mdx": "^1.6.19",
"@mdx-js/react": "^1.6.19",
"@newrelic/gatsby-theme-newrelic": "^4.0.5",
"@splitsoftware/splitio-react": "^1.2.0",
"gatsby": "^4.5.3",
"gatsby-plugin-gatsby-cloud": "^4.5.2",
"gatsby-source-filesystem": "^4.5.2",
"gatsby-transformer-json": "^4.5.0",
"gatsby-transformer-sharp": "^3.13.0",
"gatsby-plugin-emotion": "^6.8.0",
"gatsby-plugin-manifest": "^3.13.0",
"gatsby-plugin-meta-redirect": "^1.1.1",
"gatsby-plugin-mdx": "^2.8.0",
"gatsby-plugin-use-query-params": "^1.0.1",
"gatsby-plugin-react-helmet": "^4.8.0",
"gatsby-plugin-sass": "^4.8.0",
"gatsby-plugin-sharp": "^3.14.1",
"node-sass": "^6.0.1",
"pluralize": "^8.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1"
"react-dom": "^17.0.1",
"react-helmet": "^6.1.0",
"react-markdown": "^6.0.0",
"sharp": "^0.29.1",
"use-mobile-detect-hook": "^1.0.4",
"use-query-params": "^1.2.2"
},
"devDependencies": {
"@newrelic/eslint-plugin-newrelic": "^0.3.1",
"babel-jest": "^26.0.1",
"babel-preset-gatsby": "^1.0.0",
"prettier": "2.2.1"
}
}
Loading

0 comments on commit a55931f

Please sign in to comment.