Skip to content
This repository was archived by the owner on Apr 15, 2021. It is now read-only.

Commit 70f753f

Browse files
committed
WIP constants
1 parent b4bf244 commit 70f753f

File tree

11 files changed

+55
-33
lines changed

11 files changed

+55
-33
lines changed

components/Header.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Logo from './Logo'
2222
import Router from 'next/router'
2323
import clsx from 'clsx'
2424
import HeaderCollapseMenu from './HeaderCollapseMenu'
25+
import { APP_URL, FORUM_URL, STATUS_URL } from '../consts'
2526

2627
const useStyles = makeStyles(theme => ({
2728
appBar: {
@@ -147,7 +148,7 @@ export default function Header() {
147148
<div style={{ flex: 1 }} className={classes.smUp} />
148149
<Hidden smDown implementation="css">
149150
<Button
150-
href="https://moovweb.app/signup?redirectTo=/"
151+
href={`${APP_URL}/signup?redirectTo=/`}
151152
target="_blank"
152153
className={classes.signUpButton}
153154
variant="outlined"
@@ -156,20 +157,20 @@ export default function Header() {
156157
</Button>
157158
</Hidden>
158159
<Hidden mdDown implementation="css">
159-
<Button href="https://moovweb.app" target="_blank" className={classes.button}>
160+
<Button href={APP_URL} target="_blank" className={classes.button}>
160161
LOGIN
161162
</Button>
162163
</Hidden>
163164
<Hidden smDown implementation="css">
164-
<Button href="https://forum.moovweb.com" target="_blank" className={classes.button}>
165+
<Button href={FORUM_URL} target="_blank" className={classes.button}>
165166
FORUMS
166167
</Button>
167-
<Button href="https://status.moovweb.com" target="_blank" className={classes.button}>
168+
<Button href={STATUS_URL} target="_blank" className={classes.button}>
168169
STATUS
169170
</Button>
170171
</Hidden>
171172
<Hidden mdDown implementation="css">
172-
<Button href="https://moovweb.app/help" target="_blank" className={classes.button}>
173+
<Button href={`${APP_URL}/help`} target="_blank" className={classes.button}>
173174
SUPPORT
174175
</Button>
175176
</Hidden>

components/HeaderCollapseMenu.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Link from 'next/link'
66
import { MoreVert } from '@material-ui/icons'
77
import { makeStyles } from '@material-ui/core/styles'
88
import { Hidden } from '@material-ui/core'
9+
import { APP_URL, FORUM_URL, STATUS_URL, HELP_URL } from '../consts'
910

1011
const useStyles = makeStyles(theme => ({
1112
root: {
@@ -57,30 +58,30 @@ export default function HeaderCollapseMenu({ className }) {
5758
>
5859
<HideWhenLarge mdUp implementation="css">
5960
<MenuItem onClick={handleClose}>
60-
<Link href="https://moovweb.app/signup?redirectTo=/">
61+
<Link href={`${APP_URL}/signup?redirectTo=/`}>
6162
<a>SIGN UP</a>
6263
</Link>
6364
</MenuItem>
6465
</HideWhenLarge>
6566
<MenuItem onClick={handleClose}>
66-
<Link href="https://moovweb.app">
67+
<Link href={APP_URL}>
6768
<a>SIGN IN</a>
6869
</Link>
6970
</MenuItem>
7071
<HideWhenLarge mdUp implementation="css">
7172
<MenuItem onClick={handleClose}>
72-
<Link href="https://forum.moovweb.com">
73+
<Link href={FORUM_URL}>
7374
<a>FORUMS</a>
7475
</Link>
7576
</MenuItem>
7677
</HideWhenLarge>
7778
<MenuItem onClick={handleClose}>
78-
<Link href="https://help.moovweb.com">
79+
<Link href={HELP_URL}>
7980
<a>SUPPORT</a>
8081
</Link>
8182
</MenuItem>
8283
<MenuItem onClick={handleClose}>
83-
<Link href="https://status.moovweb.com">
84+
<Link href={STATUS_URL}>
8485
<a>STATUS</a>
8586
</Link>
8687
</MenuItem>

components/utils/useSegment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
22
import { useRouter } from 'next/router'
33

44
export default function useSegment() {
5-
const MOOVWEB = 'moovweb.'
5+
const LAYERZ = 'moovweb.'
66
const RSF = 'reactstorefront.'
77

88
const { asPath, query } = useRouter()
@@ -39,7 +39,7 @@ export default function useSegment() {
3939

4040
anchors.forEach(anchor => {
4141
if (
42-
(anchor.href.includes(MOOVWEB) || anchor.href.includes(RSF)) &&
42+
(anchor.href.includes(LAYERZ) || anchor.href.includes(RSF)) &&
4343
!anchor.href.includes(window.location.hostname)
4444
) {
4545
const url = new URL(anchor.href)

consts.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const PRODUCT_NAME = 'Layer0'
2+
export const CLI_NAME = 'l0'
3+
4+
export const DOMAIN = 'layer0.co'
5+
export const APP_DOMAIN = `app.${DOMAIN}`
6+
export const DOCS_DOMAIN = `developer.${DOMAIN}`
7+
8+
export const APP_URL = `https://${APP_DOMAIN}`
9+
export const FORUM_URL = `https://forum.${DOMAIN}`
10+
export const STATUS_URL = `https://status.${DOMAIN}`
11+
export const HELP_URL = `https://help.${DOMAIN}`
12+
export const DOCS_PAGES_REPO_URL = 'https://moovweb-docs.github.io/xdn-docs-pages'

pages/_app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ new Metrics({ token: 'cdc8d6df-476b-4e2d-ae1a-f8c6893a39a8' }).collect()
2020
export default function MyApp({ Component, pageProps, currentVersion, versions }) {
2121
useJssStyles()
2222

23-
// We add segment id to every moovweb.app/rsf anchor
23+
// We add segment id to every app.layer0.co/rsf anchor
2424
useSegment()
2525

2626
const toc = useRef()

pages/_document.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import Document, { Html, Head, Main, NextScript } from 'next/document'
33
import { ServerStyleSheets } from '@material-ui/core/styles'
44
import theme from '../components/theme'
5+
import { DOCS_DOMAIN } from '../consts'
56

67
class MyDocument extends Document {
78
render() {
@@ -11,7 +12,7 @@ class MyDocument extends Document {
1112
<script
1213
dangerouslySetInnerHTML={{
1314
__html: `
14-
const gtmID = window.location.hostname == "developer.moovweb.com" ? "GTM-5XH2P83" : "GTM-PQWGJWT";
15+
const gtmID = window.location.hostname == "${DOCS_DOMAIN}" ? "GTM-5XH2P83" : "GTM-PQWGJWT";
1516
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
1617
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
1718
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
@@ -23,7 +24,7 @@ class MyDocument extends Document {
2324
dangerouslySetInnerHTML={{
2425
__html: `
2526
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics._writeKey="gER2Fq4athAwZDM4MmmqBC9aI02BK1MI";analytics.SNIPPET_VERSION="4.13.2";
26-
analytics.load(window.location.hostname == "developer.moovweb.com" ? "gER2Fq4athAwZDM4MmmqBC9aI02BK1MI" : "CGpFCA06VrpwNIUbgqUuPpTrIIoIthzs");
27+
analytics.load(window.location.hostname == "${DOCS_DOMAIN}" ? "gER2Fq4athAwZDM4MmmqBC9aI02BK1MI" : "CGpFCA06VrpwNIUbgqUuPpTrIIoIthzs");
2728
analytics.page();
2829
}}();
2930
`,

pages/api/guides.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import fetch from 'isomorphic-fetch'
2+
import { DOCS_PAGES_REPO_URL } from '../../consts'
23

34
export default async function guides(req, res) {
45
const { version } = req.query
56
const guides = version
6-
? await fetch(
7-
`https://moovweb-docs.github.io/xdn-docs-pages/${version}/guides.json`,
8-
).then(resp => resp.json())
7+
? await fetch(`${DOCS_PAGES_REPO_URL}/${version}/guides.json`).then(resp => resp.json())
98
: require('../../guides/guides.json')
109

1110
if (res) {

pages/api/guides/[guide].js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fetch from 'isomorphic-fetch'
2+
import { DOCS_PAGES_REPO_URL } from '../../../consts'
23

34
export default async function guide(req, res) {
45
let { version, guide } = req.query
@@ -14,9 +15,9 @@ export default async function guide(req, res) {
1415
// To allow correct previews in local/cloud/edge, read the versioned docs only in production,
1516
// otherwise just read it from this version itself.
1617
process.env.XDN_ENVIRONMENT_NAME === 'production' || isChangelog
17-
? await fetch(
18-
`http://moovweb-docs.github.io/xdn-docs-pages/${version}/guides/${guide}.md`,
19-
).then(resp => resp.text())
18+
? await fetch(`${DOCS_PAGES_REPO_URL}/${version}/guides/${guide}.md`).then(resp =>
19+
resp.text(),
20+
)
2021
: require(`../../../guides/${guide}.md`).default
2122

2223
if (res) {

pages/api/modules/[version].js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import fetch from 'isomorphic-fetch'
2+
import { DOCS_PAGES_REPO_URL } from '../../../consts'
23

34
export default async function version(req, res) {
45
const { version } = req.query
5-
const modules = await fetch(
6-
`http://moovweb-docs.github.io/xdn-docs-pages/${version}/modules.json`,
7-
).then(resp => resp.json())
6+
const modules = await fetch(`${DOCS_PAGES_REPO_URL}/${version}/modules.json`).then(resp =>
7+
resp.json(),
8+
)
89

910
const updateMenu = node => {
1011
if (node.as) {

pages/guides/[...guide].js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import getBaseUrl from '../../components/utils/getBaseUrl'
99
import ApiLink from '../../components/ApiLink'
1010
import { Typography } from '@material-ui/core'
1111
import { useTheme } from '@material-ui/styles'
12+
import { PRODUCT_NAME } from '../../consts'
1213

1314
export default function Guide({ notFound, markdown, navData, guide }) {
1415
if (notFound) {
@@ -34,7 +35,9 @@ export default function Guide({ notFound, markdown, navData, guide }) {
3435
nav={<Nav navData={navData} aboveAdornments={[<ApiLink key="link" />]} />}
3536
>
3637
<Head>
37-
<title>Moovweb XDN Documentation {pageTitle ? `- ${pageTitle}` : ''}</title>
38+
<title>
39+
{PRODUCT_NAME} Documentation {pageTitle ? `- ${pageTitle}` : ''}
40+
</title>
3841
</Head>
3942
<Markdown source={markdown} toc />
4043
<Footer navData={navData} guide={guide} />

0 commit comments

Comments
 (0)