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

Commit

Permalink
Merge pull request #8 from newrelic/campfire/io-frontend
Browse files Browse the repository at this point in the history
Move I/O Frontend Code
  • Loading branch information
josephgregoryii authored Jan 27, 2022
2 parents 8c0d9ef + 65d45f3 commit c1166b5
Show file tree
Hide file tree
Showing 73 changed files with 10,767 additions and 706 deletions.
41 changes: 41 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
// https://github.com/newrelic/eslint-plugin-newrelic
extends: [
'plugin:@newrelic/eslint-plugin-newrelic/react',
'plugin:@newrelic/eslint-plugin-newrelic/prettier',
'plugin:jsx-a11y/recommended',
'plugin:react-hooks/recommended',
],
// https://github.com/yannickcr/eslint-plugin-react#configuration
plugins: ['react', 'jsx-a11y', 'markdown'],
settings: {
react: {
version: 'detect',
},
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
env: {
browser: true,
es6: true,
},
ignorePatterns: ['**/__tests__/**/*'],
rules: {
'jsx-a11y/no-onchange': 0,
'no-unused-vars': [
'error',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
ignoreRestSiblings: false,
},
],
},
};
106 changes: 106 additions & 0 deletions .github/workflows/fetch-related-content.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Fetch related pages from Swiftype

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # start of every day

env:
BOT_NAME: nr-opensource-bot
BOT_EMAIL: [email protected]

jobs:
fetch-swiftype-results:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
ref: main

- name: Setup node.js
uses: actions/setup-node@v1
with:
node-version: 16

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Gatsby Build
run: yarn run build:related-content

- name: Temporarily disable branch protection
id: disable-branch-protection
uses: actions/github-script@v1
with:
github-token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
previews: luke-cage-preview
script: |
const result = await github.repos.updateBranchProtection({
owner: context.repo.owner,
repo: context.repo.repo,
branch: 'main',
required_status_checks: null,
restrictions: null,
enforce_admins: null,
required_pull_request_reviews: null
})
console.log("Result:", result)
- name: Commit changes
id: commit-changes
run: |
git config --local user.email "${{ env.BOT_EMAIL }}"
git config --local user.name "${{ env.BOT_NAME }}"
git add ./src/data/related-pages.json
git commit -m 'chore(related-content): updated related content data'
echo "::set-output name=commit::true"
# Push directly to `main` branch because we want updates to the related
# content to trigger a deploy. If we commit directly to the `develop`
# branch, it would require a PR from the team to deploy the changes.
- name: Push Commit
if: steps.commit-changes.outputs.commit == 'true'
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
branch: main

- name: Re-enable branch protection
id: enable-branch-protection
if: always()
uses: actions/github-script@v1
with:
github-token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
previews: luke-cage-preview
script: |
const result = await github.repos.updateBranchProtection({
owner: context.repo.owner,
repo: context.repo.repo,
branch: 'main',
required_status_checks: {
strict: false,
contexts: [
'Gatsby Build Service - instant-observability-website'
]
},
restrictions: null,
enforce_admins: true,
required_pull_request_reviews: {
dismiss_stale_reviews: true,
required_approving_review_count: 1
}
})
console.log("Result:", result)
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
9 changes: 9 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
trailingComma: 'es5',
printWidth: 80,
tabWidth: 2,
semi: true,
singleQuote: true,
jsxSingleQuote: false,
arrowParens: 'always',
};
143 changes: 135 additions & 8 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,158 @@
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 === 'Quickstarts') {
return resolveQuickstartSlug(node.name, node.id);
}
},
getParams: ({ node }) => {
let tags = node.keywords;
let 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.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",
resolve: 'gatsby-source-filesystem',
options: {
name: "quickstarts",
name: 'quickstarts',
path: `${__dirname}/src/data/quickstarts.json`,
},
},
{
resolve: "gatsby-transformer-json",
resolve: 'gatsby-transformer-json',
options: {
// If we need to source json files other than the i18n/nav, we should
// consider making this dynamic. See the docs for ways to do this.
//
// https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-transformer-json
typeName: "Quickstarts",
typeName: 'Quickstarts',
},
},
'gatsby-plugin-mdx',
'gatsby-plugin-meta-redirect',
'gatsby-plugin-use-query-params',
{
resolve: "gatsby-plugin-gatsby-cloud",
resolve: 'gatsby-plugin-gatsby-cloud',
options: {
allPageHeaders: ["Referrer-Policy: no-referrer-when-downgrade"],
allPageHeaders: ['Referrer-Policy: no-referrer-when-downgrade'],
},
},
],
};

Loading

0 comments on commit c1166b5

Please sign in to comment.