Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit dfd5bac

Browse files
jyecuschdavemooreuwsHomelessDinosaur
authored
docs next (#610)
Co-authored-by: David Moore <[email protected]> Co-authored-by: Ryan Cartwright <[email protected]>
1 parent f60bf89 commit dfd5bac

File tree

1,349 files changed

+65222
-56007
lines changed

Some content is hidden

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

1,349 files changed

+65222
-56007
lines changed

.github/workflows/test.yaml

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
NEXT_PUBLIC_VERCEL_URL: nitric.io
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
1818
- uses: actions/setup-node@v3
1919
with:
2020
node-version: 18
@@ -27,43 +27,25 @@ jobs:
2727
run: yarn format:check
2828
- name: Run spellcheck test
2929
run: yarn test:spellcheck
30-
- name: Build Website
31-
run: yarn build
32-
env:
33-
NEXT_PUBLIC_GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
34-
- name: Cache Build
35-
uses: actions/cache@v2
36-
id: restore-build
37-
with:
38-
path: |
39-
.next
40-
public
41-
key: ci-docs-test-${{ github.sha }}
4230

4331
test-broken-links:
4432
runs-on: ubuntu-latest
4533
needs: [tests]
4634
steps:
4735
- name: Checkout
48-
uses: actions/checkout@v2
49-
- name: Restore Build
50-
uses: actions/cache@v2
51-
id: restore-build
52-
with:
53-
path: |
54-
.next
55-
public
56-
key: ci-docs-test-${{ github.sha }}
36+
uses: actions/checkout@v3
5737
- name: Cypress tests 🧪
5838
uses: cypress-io/github-action@v5
5939
with:
6040
headless: true
6141
config: video=false
6242
browser: chrome
6343
spec: cypress/e2e/broken-links.cy.ts
64-
build: node scripts/build-pages-fixture.js
44+
build: yarn cypress:build
6545
start: yarn start
6646
wait-on: 'http://localhost:3000'
47+
env:
48+
NEXT_PUBLIC_GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
6749
- name: Upload screenshots
6850
uses: actions/upload-artifact@v4
6951
if: failure()
@@ -76,25 +58,19 @@ jobs:
7658
needs: [tests]
7759
steps:
7860
- name: Checkout
79-
uses: actions/checkout@v2
80-
- name: Restore Build
81-
uses: actions/cache@v2
82-
id: restore-build
83-
with:
84-
path: |
85-
.next
86-
public
87-
key: ci-docs-test-${{ github.sha }}
61+
uses: actions/checkout@v3
8862
- name: Cypress tests 🧪
8963
uses: cypress-io/github-action@v5
9064
with:
9165
headless: true
9266
config: video=false
9367
browser: chrome
9468
spec: cypress/e2e/a11y.cy.ts
95-
build: node scripts/build-pages-fixture.js
69+
build: yarn cypress:build
9670
start: yarn start
9771
wait-on: 'http://localhost:3000'
72+
env:
73+
NEXT_PUBLIC_GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
9874
- name: Upload screenshots
9975
uses: actions/upload-artifact@v4
10076
if: failure()
@@ -107,25 +83,19 @@ jobs:
10783
needs: [tests]
10884
steps:
10985
- name: Checkout
110-
uses: actions/checkout@v2
111-
- name: Restore Build
112-
uses: actions/cache@v2
113-
id: restore-build
114-
with:
115-
path: |
116-
.next
117-
public
118-
key: ci-docs-test-${{ github.sha }}
86+
uses: actions/checkout@v3
11987
- name: Cypress tests 🧪
12088
uses: cypress-io/github-action@v5
12189
with:
12290
headless: true
12391
config: video=false
12492
browser: chrome
12593
spec: cypress/e2e/seo.cy.ts
126-
build: node scripts/build-pages-fixture.js
94+
build: yarn cypress:build
12795
start: yarn start
12896
wait-on: 'http://localhost:3000'
97+
env:
98+
NEXT_PUBLIC_GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
12999
- name: Upload screenshots
130100
uses: actions/upload-artifact@v4
131101
if: failure()

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,17 @@
2323
npm-debug.log*
2424
yarn-debug.log*
2525
yarn-error.log*
26-
.pnpm-debug.log*
2726

2827
# local env files
2928
.env*.local
3029

3130
# vercel
3231
.vercel
32+
33+
# typescript
34+
*.tsbuildinfo
35+
next-env.d.ts
36+
37+
.contentlayer
38+
39+
old

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn lint-staged

.spellcheckerrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
files:
2-
- 'src/pages/**/*.{md,mdx}'
2+
- 'docs/**/*.{md,mdx}'
33
dictionaries:
44
- dictionary.txt
55
quiet: true

components.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
{
22
"$schema": "https://ui.shadcn.com/schema.json",
3-
"style": "default",
4-
"rsc": false,
3+
"style": "new-york",
4+
"rsc": true,
55
"tsx": true,
66
"tailwind": {
7-
"config": "tailwind.config.js",
7+
"config": "tailwind.config.ts",
88
"css": "src/styles/tailwind.css",
9-
"baseColor": "slate",
9+
"baseColor": "zinc",
1010
"cssVariables": true,
1111
"prefix": ""
1212
},
1313
"aliases": {
1414
"components": "@/components",
15-
"utils": "@/lib/utils"
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
1619
}
1720
}

contentlayer.config.ts

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import { defineDocumentType, makeSource } from 'contentlayer2/source-files'
2+
import { extractTocHeadings } from './src/mdx/remark-toc-headings.mjs'
3+
import path from 'path'
4+
import fs from 'fs'
5+
6+
const contentDirPath = 'docs'
7+
8+
const branch = process.env.NEXT_PUBLIC_GITHUB_BRANCH || 'main'
9+
10+
const Doc = defineDocumentType(() => ({
11+
name: 'Doc',
12+
filePathPattern: '**/*.mdx',
13+
fields: {
14+
title_seo: {
15+
type: 'string',
16+
description:
17+
'The meta title of the doc, this will override the title extracted from the markdown and the nav title',
18+
},
19+
description: {
20+
type: 'string',
21+
description: 'The description of the doc',
22+
},
23+
image: {
24+
type: 'string',
25+
description: 'The image of the doc',
26+
},
27+
image_alt: {
28+
type: 'string',
29+
description: 'The image alt of the doc',
30+
},
31+
disable_edit: {
32+
type: 'boolean',
33+
description: 'Disable the github edit button',
34+
},
35+
tags: {
36+
type: 'list',
37+
of: {
38+
type: 'string',
39+
},
40+
description: 'The tags of the post, used by guides',
41+
},
42+
},
43+
computedFields: {
44+
slug: {
45+
type: 'string',
46+
resolve: (doc) => doc._raw.flattenedPath,
47+
},
48+
toc: { type: 'json', resolve: (doc) => extractTocHeadings(doc.body.raw) },
49+
title: {
50+
type: 'string',
51+
resolve: async (doc) => {
52+
const headings = await extractTocHeadings(doc.body.raw, [1])
53+
54+
return headings[0]?.value
55+
},
56+
},
57+
editUrl: {
58+
type: 'string',
59+
resolve: (doc) =>
60+
`https://github.com/nitrictech/docs/edit/${branch}/docs/${doc._raw.sourceFilePath}`,
61+
},
62+
lastModified: {
63+
type: 'date',
64+
resolve: (doc) => {
65+
// Get the full path to the markdown file
66+
const filePath = path.join(
67+
process.cwd(),
68+
contentDirPath,
69+
doc._raw.sourceFilePath,
70+
)
71+
// Extract and return the last modified date
72+
const stats = fs.statSync(filePath)
73+
return stats.mtime // This is the last modified date
74+
},
75+
},
76+
},
77+
}))
78+
79+
export default makeSource({
80+
contentDirPath,
81+
documentTypes: [Doc],
82+
})

cypress.config.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ export default defineConfig({
44
e2e: {
55
baseUrl: 'http://localhost:3000',
66
setupNodeEvents(on, config) {
7-
// require("cypress-fail-fast/plugin")(on, config);
8-
return config
7+
on('task', {
8+
log(message) {
9+
console.log(message)
10+
11+
return null
12+
},
13+
table(message) {
14+
console.table(message)
15+
16+
return null
17+
},
18+
})
919
},
1020
},
1121
})

cypress/e2e/a11y.cy.ts

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,72 @@ import * as pages from '../fixtures/pages.json'
22

33
describe('a11y accessiblity test suite', () => {
44
pages.forEach((page) => {
5-
it(`Should test page ${page} for a11y violations`, () => {
5+
it(`Should test page ${page} for a11y violations on desktop`, () => {
66
cy.viewport('macbook-16')
77
cy.visit(page)
88
cy.injectAxe()
9-
cy.wait(150)
9+
cy.wait(500)
1010
cy.checkA11y(
1111
undefined,
1212
{
1313
includedImpacts: ['critical'],
1414
},
15-
);
15+
(violations) => {
16+
cy.task(
17+
'log',
18+
`${violations.length} accessibility violation${
19+
violations.length === 1 ? '' : 's'
20+
} ${violations.length === 1 ? 'was' : 'were'} detected`,
21+
)
22+
// pluck specific keys to keep the table readable
23+
const violationData = violations.map(
24+
({ id, impact, description, nodes }) => ({
25+
id,
26+
impact,
27+
description,
28+
nodes: nodes.length,
29+
}),
30+
)
31+
32+
cy.task('table', violationData)
33+
34+
// console.error(JSON.stringify(violations));
35+
},
36+
)
37+
})
38+
39+
it(`Should test page ${page} for a11y violations on mobile`, () => {
40+
cy.viewport('iphone-x')
41+
cy.visit(page)
42+
cy.injectAxe()
43+
cy.wait(500)
44+
cy.checkA11y(
45+
undefined,
46+
{
47+
includedImpacts: ['critical'],
48+
},
49+
(violations) => {
50+
cy.task(
51+
'log',
52+
`${violations.length} accessibility violation${
53+
violations.length === 1 ? '' : 's'
54+
} ${violations.length === 1 ? 'was' : 'were'} detected`,
55+
)
56+
// pluck specific keys to keep the table readable
57+
const violationData = violations.map(
58+
({ id, impact, description, nodes }) => ({
59+
id,
60+
impact,
61+
description,
62+
nodes: nodes.length,
63+
}),
64+
)
65+
66+
cy.task('table', violationData)
67+
68+
// console.error(JSON.stringify(violations));
69+
},
70+
)
1671
})
1772
})
1873
})

0 commit comments

Comments
 (0)