Skip to content

Commit 3200af3

Browse files
authored
chore(website): update website wrt to current docs (#979)
* Update wrt to current docs * example page added for mdx frontmatter
1 parent 12afc7d commit 3200af3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1163
-375
lines changed

website/.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,10 @@ yarn-error.log
6969
# Yarn Integrity file
7070
.yarn-integrity
7171

72-
.envrc
72+
.envrc
73+
74+
# Example page
75+
# content/00-example.mdx
76+
77+
# History
78+
.history/

website/.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
public/
3+
.cache/
4+
static/

website/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ This repository contains the [source code](./src) and the [content](./content) f
99
Download the code and get started by running the following commands:
1010

1111
```
12-
git clone [email protected]:graphql-nexus/docs.git
13-
cd docs
12+
git clone [email protected]:graphql-nexus.git
13+
cd nexus
14+
cd website
1415
yarn
1516
yarn dev
1617
```

website/config.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@ const config = {
33
pathPrefix: '',
44
siteUrl: 'https://www.nexusjs.org', // replace with nexus site
55
},
6+
redirects: [],
67
header: {
78
logoLink: 'https://www.nexusjs.org', // replace with nexus site
89
title: 'GraphQL Nexus',
910
// check all links
10-
links: [
11-
{ name: 'Docs', link: 'https://www.nexusjs.org/docs' },
12-
{ name: 'Quickstart', link: 'https://www.prisma.io/docs/getting-started/quickstart' },
13-
{
14-
name: 'Reference',
15-
link: 'https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/api',
16-
},
17-
{ name: 'Blog', link: 'https://www.prisma.io/blog/' },
18-
{ name: 'Community', link: 'https://www.prisma.io/community/' },
19-
{ name: 'FAQ', link: 'https://www.prisma.io/docs/more/faq' },
20-
],
11+
// links: [
12+
// { name: 'Docs', link: 'https://www.nexusjs.org/docs' },
13+
// { name: 'Quickstart', link: 'https://www.prisma.io/docs/getting-started/quickstart' },
14+
// {
15+
// name: 'Reference',
16+
// link: 'https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/api',
17+
// },
18+
// { name: 'Blog', link: 'https://www.prisma.io/blog/' },
19+
// { name: 'Community', link: 'https://www.prisma.io/community/' },
20+
// { name: 'FAQ', link: 'https://www.prisma.io/docs/more/faq' },
21+
// ],
22+
links: [{ name: '', link: '' }],
2123
search: {
2224
indexName: process.env.GATSBY_ALGOLIA_INDEX_NAME,
2325
algoliaAppId: process.env.GATSBY_ALGOLIA_APP_ID,
@@ -29,7 +31,7 @@ const config = {
2931
title: 'GraphQL Nexus - title',
3032
description: 'GraphQL Nexus - desc',
3133
keywords: 'Docs, nexus, 1.0',
32-
docsLocation: 'https://github.com/graphql-nexus/docs/tree/master/content',
34+
docsLocation: 'https://github.com/graphql-nexus/nexus/tree/master/website/content',
3335
twitter: {
3436
site: '@nexus',
3537
creator: '@nexus',
@@ -48,7 +50,10 @@ const config = {
4850
},
4951
},
5052
feedback: {
51-
function_name: 'https://nexus-docs.netlify.app/.netlify/functions/index', // Replace with correct one
53+
function_name: '', // Replace with correct one
54+
},
55+
sidebar: {
56+
tablet_menu_split: [], // Slugs for top level folders which should appear in right pane on tablet
5257
},
5358
footer: {
5459
logoLink: '/',

website/content/00-example.mdx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: "Example"
3+
metaTitle: "Example metaTitle"
4+
metaDescription: "Example meta desc"
5+
staticLink: false
6+
experimental: false
7+
duration: "2 min"
8+
hidePage: true
9+
toc: false
10+
---
11+
12+
## Overview
13+
14+
This page won't be shown in sidebar. <FileWithIcon text="schema.ts" icon="file"/> For now, h2 tags cannot be written inside `SwitchTech` block. But still can include headings using `<h3>, <h4>` tags and not using `### headings`.
15+
`<h2>` tags wont be shown in TOC yet.
16+
```js
17+
sdd
18+
```
19+
20+
21+
<TabbedContent tabs={["Using include", "Fluent API"]}>
22+
<Tab>
23+
24+
25+
```ts
26+
const posts = await prisma.user.findOne({
27+
where: {
28+
id: 2,
29+
},
30+
include: {
31+
post: true,
32+
},
33+
});
34+
```
35+
</Tab>
36+
<Tab>
37+
38+
```ts
39+
const posts = await prisma.user.findOne({
40+
where: {
41+
id: 2,
42+
},
43+
include: {
44+
post: true,
45+
},
46+
});
47+
```
48+
</Tab>
49+
</TabbedContent>

website/functions/index.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
1-
const { PrismaClient } = require('@prisma/client');
1+
const { PrismaClient } = require('@prisma/client')
22

3-
const client = new PrismaClient();
3+
const client = new PrismaClient()
44

55
exports.handler = async function(event, context, callback) {
6-
const body = JSON.parse(event.body);
7-
6+
const body = JSON.parse(event.body)
87
if (!body.pageUrl) {
9-
throw new Error(`Please provide a pageUrl`);
8+
throw new Error(`Please provide a pageUrl`)
109
}
1110

1211
if (!body.sentiment) {
13-
throw new Error(`Please provide a sentiment`);
12+
throw new Error(`Please provide a sentiment`)
1413
}
1514

1615
if (!['Happy', 'Unhappy'].includes(body.sentiment)) {
17-
throw new Error(`Please provide "Happy" or "Unhappy" as the sentiment`);
16+
throw new Error(`Please provide "Happy" or "Unhappy" as the sentiment`)
1817
}
18+
const pageUrl = stripTrailingSlash(body.pageUrl)
1919

2020
await client.feedback.create({
2121
data: {
22+
pageUrl,
2223
ip: event.headers['x-forwarded-for'],
23-
pageUrl: body.pageUrl,
2424
userAgent: event.headers['user-agent'],
2525
sentiment: body.sentiment,
2626
},
27-
});
27+
})
2828

2929
return {
3030
statusCode: 200,
3131
body: JSON.stringify({ success: true }),
3232
headers: {
3333
'Access-Control-Allow-Origin': '*',
3434
},
35-
};
36-
};
35+
}
36+
}
37+
38+
function stripTrailingSlash(url) {
39+
return url.replace(/\/$/, '')
40+
}
41+

website/gatsby-browser.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
// require('prismjs/themes/prism.css');
1+
const { init, trackPage } = require('./src/utils/stats')
2+
const { goToNav } = require('./src/utils/goToNavItem')
3+
4+
exports.onClientEntry = () => {
5+
init()
6+
}
7+
8+
exports.onRouteUpdate = ({ location }) => {
9+
trackPage(location.pathname)
10+
goToNav(location.pathname)
11+
}

website/gatsby-config.js

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,27 @@ const gatsbyRemarkPlugins = [
1818
{
1919
resolve: `gatsby-remark-images`,
2020
},
21+
{
22+
resolve: `gatsby-remark-images`,
23+
options: {
24+
disableBgImageOnAlpha: true,
25+
},
26+
},
27+
{
28+
resolve: require.resolve('./plugins/gatsby-remark-to-absoluteurl'),
29+
options: {
30+
redirects: config.redirects,
31+
},
32+
},
33+
{
34+
resolve: require.resolve('./plugins/gatsby-remark-check-links-numberless'),
35+
},
36+
{
37+
resolve: 'gatsby-remark-copy-linked-files',
38+
options: {
39+
destinationDir: 'static',
40+
},
41+
},
2142
]
2243

2344
module.exports = {
@@ -35,13 +56,13 @@ module.exports = {
3556
docsLocation: config.siteMetadata.docsLocation,
3657
},
3758
plugins: [
38-
{
39-
resolve: `gatsby-plugin-google-analytics`,
40-
options: {
41-
trackingId: 'UA-74131346-14',
42-
anonymize: true,
43-
},
44-
},
59+
// {
60+
// resolve: `gatsby-plugin-google-analytics`,
61+
// options: {
62+
// trackingId: 'UA-74131346-14',
63+
// anonymize: true,
64+
// },
65+
// },
4566
'gatsby-plugin-react-helmet',
4667
'gatsby-transformer-sharp',
4768
'gatsby-plugin-sharp',
@@ -63,10 +84,12 @@ module.exports = {
6384
{
6485
resolve: 'gatsby-plugin-robots-txt',
6586
options: {
66-
policy: [{
67-
userAgent: '*',
68-
disallow: '/'
69-
}]
87+
policy: [
88+
{
89+
userAgent: '*',
90+
disallow: '/',
91+
},
92+
],
7093
},
7194
},
7295
// 'gatsby-plugin-offline', // it causes infinite loop issue with workbox

website/gatsby-node.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ exports.onCreateNode = ({ node, getNode, actions }) => {
1919
name: 'id',
2020
value: node.id,
2121
})
22+
createNodeField({
23+
node,
24+
name: 'modSlug',
25+
value: `/${value.replace('/index', '')}`,
26+
})
2227
}
2328
}
2429

@@ -34,6 +39,7 @@ exports.createPages = ({ graphql, actions }) => {
3439
fields {
3540
slug
3641
id
42+
modSlug
3743
}
3844
frontmatter {
3945
title

website/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"gatsby-image": "^2.0.33",
1616
"gatsby-plugin-algolia": "^0.5.0",
1717
"gatsby-plugin-catch-links": "^2.3.0",
18-
"gatsby-plugin-google-analytics": "^2.2.4",
1918
"gatsby-plugin-manifest": "^2.0.24",
2019
"gatsby-plugin-mdx": "^1.0.73",
2120
"gatsby-plugin-offline": "^2.0.25",
@@ -28,8 +27,10 @@
2827
"gatsby-plugin-styled-components": "^3.0.7",
2928
"gatsby-plugin-typescript": "^2.0.11",
3029
"gatsby-remark-autolink-headers": "^2.2.1",
30+
"gatsby-remark-copy-linked-files": "^2.3.2",
3131
"gatsby-remark-images": "^3.2.1",
3232
"gatsby-remark-prismjs": "^3.2.5",
33+
"gatsby-remark-rewrite-relative-links": "^1.0.8",
3334
"gatsby-source-filesystem": "^2.0.24",
3435
"gatsby-source-remote-file": "^0.1.9",
3536
"gatsby-transformer-remark": "^2.3.2",
@@ -43,6 +44,7 @@
4344
"react": "^16.8.4",
4445
"react-copy-to-clipboard": "^5.0.2",
4546
"react-dom": "^16.8.4",
47+
"react-ga": "^2.7.0",
4648
"react-helmet": "^6.0.0",
4749
"react-hooks-global-state": "^1.0.0",
4850
"react-hooks-testing-library": "^0.3.6",
@@ -62,10 +64,10 @@
6264
"license": "MIT",
6365
"scripts": {
6466
"clean": "gatsby clean",
65-
"build": "GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --prefix-paths --log-pages",
67+
"build": "gatsby build --prefix-paths --log-pages",
6668
"dev": "gatsby develop",
6769
"serve": "yarn build && gatsby serve --prefix-paths -o",
68-
"prettify": "prettier --write \"src/**/*.css\" \"src/**/*.ts\" \"src/**/*.tsx\" \"content/**/*.mdx\"",
70+
"prettify": "prettier --write \"**/*.{js,mdx,json,md,ts,tsx,yml,toml,graphql,css}\"",
6971
"test": "jest"
7072
},
7173
"devDependencies": {

0 commit comments

Comments
 (0)