Skip to content

Commit

Permalink
docs next (#610)
Browse files Browse the repository at this point in the history
Co-authored-by: David Moore <[email protected]>
Co-authored-by: Ryan Cartwright <[email protected]>
  • Loading branch information
3 people authored Oct 11, 2024
1 parent f60bf89 commit dfd5bac
Show file tree
Hide file tree
Showing 1,349 changed files with 65,222 additions and 56,007 deletions.
56 changes: 13 additions & 43 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
NEXT_PUBLIC_VERCEL_URL: nitric.io
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
Expand All @@ -27,43 +27,25 @@ jobs:
run: yarn format:check
- name: Run spellcheck test
run: yarn test:spellcheck
- name: Build Website
run: yarn build
env:
NEXT_PUBLIC_GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
- name: Cache Build
uses: actions/cache@v2
id: restore-build
with:
path: |
.next
public
key: ci-docs-test-${{ github.sha }}

test-broken-links:
runs-on: ubuntu-latest
needs: [tests]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Restore Build
uses: actions/cache@v2
id: restore-build
with:
path: |
.next
public
key: ci-docs-test-${{ github.sha }}
uses: actions/checkout@v3
- name: Cypress tests 🧪
uses: cypress-io/github-action@v5
with:
headless: true
config: video=false
browser: chrome
spec: cypress/e2e/broken-links.cy.ts
build: node scripts/build-pages-fixture.js
build: yarn cypress:build
start: yarn start
wait-on: 'http://localhost:3000'
env:
NEXT_PUBLIC_GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
- name: Upload screenshots
uses: actions/upload-artifact@v4
if: failure()
Expand All @@ -76,25 +58,19 @@ jobs:
needs: [tests]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Restore Build
uses: actions/cache@v2
id: restore-build
with:
path: |
.next
public
key: ci-docs-test-${{ github.sha }}
uses: actions/checkout@v3
- name: Cypress tests 🧪
uses: cypress-io/github-action@v5
with:
headless: true
config: video=false
browser: chrome
spec: cypress/e2e/a11y.cy.ts
build: node scripts/build-pages-fixture.js
build: yarn cypress:build
start: yarn start
wait-on: 'http://localhost:3000'
env:
NEXT_PUBLIC_GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
- name: Upload screenshots
uses: actions/upload-artifact@v4
if: failure()
Expand All @@ -107,25 +83,19 @@ jobs:
needs: [tests]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Restore Build
uses: actions/cache@v2
id: restore-build
with:
path: |
.next
public
key: ci-docs-test-${{ github.sha }}
uses: actions/checkout@v3
- name: Cypress tests 🧪
uses: cypress-io/github-action@v5
with:
headless: true
config: video=false
browser: chrome
spec: cypress/e2e/seo.cy.ts
build: node scripts/build-pages-fixture.js
build: yarn cypress:build
start: yarn start
wait-on: 'http://localhost:3000'
env:
NEXT_PUBLIC_GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
- name: Upload screenshots
uses: actions/upload-artifact@v4
if: failure()
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

.contentlayer

old
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn lint-staged
2 changes: 1 addition & 1 deletion .spellcheckerrc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
files:
- 'src/pages/**/*.{md,mdx}'
- 'docs/**/*.{md,mdx}'
dictionaries:
- dictionary.txt
quiet: true
Expand Down
13 changes: 8 additions & 5 deletions components.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": false,
"style": "new-york",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"config": "tailwind.config.ts",
"css": "src/styles/tailwind.css",
"baseColor": "slate",
"baseColor": "zinc",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
}
}
82 changes: 82 additions & 0 deletions contentlayer.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { defineDocumentType, makeSource } from 'contentlayer2/source-files'
import { extractTocHeadings } from './src/mdx/remark-toc-headings.mjs'
import path from 'path'
import fs from 'fs'

const contentDirPath = 'docs'

const branch = process.env.NEXT_PUBLIC_GITHUB_BRANCH || 'main'

const Doc = defineDocumentType(() => ({
name: 'Doc',
filePathPattern: '**/*.mdx',
fields: {
title_seo: {
type: 'string',
description:
'The meta title of the doc, this will override the title extracted from the markdown and the nav title',
},
description: {
type: 'string',
description: 'The description of the doc',
},
image: {
type: 'string',
description: 'The image of the doc',
},
image_alt: {
type: 'string',
description: 'The image alt of the doc',
},
disable_edit: {
type: 'boolean',
description: 'Disable the github edit button',
},
tags: {
type: 'list',
of: {
type: 'string',
},
description: 'The tags of the post, used by guides',
},
},
computedFields: {
slug: {
type: 'string',
resolve: (doc) => doc._raw.flattenedPath,
},
toc: { type: 'json', resolve: (doc) => extractTocHeadings(doc.body.raw) },
title: {
type: 'string',
resolve: async (doc) => {
const headings = await extractTocHeadings(doc.body.raw, [1])

return headings[0]?.value
},
},
editUrl: {
type: 'string',
resolve: (doc) =>
`https://github.com/nitrictech/docs/edit/${branch}/docs/${doc._raw.sourceFilePath}`,
},
lastModified: {
type: 'date',
resolve: (doc) => {
// Get the full path to the markdown file
const filePath = path.join(
process.cwd(),
contentDirPath,
doc._raw.sourceFilePath,
)
// Extract and return the last modified date
const stats = fs.statSync(filePath)
return stats.mtime // This is the last modified date
},
},
},
}))

export default makeSource({
contentDirPath,
documentTypes: [Doc],
})
14 changes: 12 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
setupNodeEvents(on, config) {
// require("cypress-fail-fast/plugin")(on, config);
return config
on('task', {
log(message) {
console.log(message)

return null
},
table(message) {
console.table(message)

return null
},
})
},
},
})
61 changes: 58 additions & 3 deletions cypress/e2e/a11y.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,72 @@ import * as pages from '../fixtures/pages.json'

describe('a11y accessiblity test suite', () => {
pages.forEach((page) => {
it(`Should test page ${page} for a11y violations`, () => {
it(`Should test page ${page} for a11y violations on desktop`, () => {
cy.viewport('macbook-16')
cy.visit(page)
cy.injectAxe()
cy.wait(150)
cy.wait(500)
cy.checkA11y(
undefined,
{
includedImpacts: ['critical'],
},
);
(violations) => {
cy.task(
'log',
`${violations.length} accessibility violation${
violations.length === 1 ? '' : 's'
} ${violations.length === 1 ? 'was' : 'were'} detected`,
)
// pluck specific keys to keep the table readable
const violationData = violations.map(
({ id, impact, description, nodes }) => ({
id,
impact,
description,
nodes: nodes.length,
}),
)

cy.task('table', violationData)

// console.error(JSON.stringify(violations));
},
)
})

it(`Should test page ${page} for a11y violations on mobile`, () => {
cy.viewport('iphone-x')
cy.visit(page)
cy.injectAxe()
cy.wait(500)
cy.checkA11y(
undefined,
{
includedImpacts: ['critical'],
},
(violations) => {
cy.task(
'log',
`${violations.length} accessibility violation${
violations.length === 1 ? '' : 's'
} ${violations.length === 1 ? 'was' : 'were'} detected`,
)
// pluck specific keys to keep the table readable
const violationData = violations.map(
({ id, impact, description, nodes }) => ({
id,
impact,
description,
nodes: nodes.length,
}),
)

cy.task('table', violationData)

// console.error(JSON.stringify(violations));
},
)
})
})
})
Loading

0 comments on commit dfd5bac

Please sign in to comment.