Skip to content

Commit 9077825

Browse files
committed
feat: migrate from docz to gatsby
1 parent be0f305 commit 9077825

File tree

120 files changed

+77962
-7439
lines changed

Some content is hidden

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

120 files changed

+77962
-7439
lines changed

build/.eslintrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"env": {
3+
"browser": false,
4+
"node": true
5+
},
6+
"parserOptions": {
7+
"sourceType": "script"
8+
},
9+
"extends": "../.eslintrc.js",
10+
"rules": {
11+
"no-console": "off",
12+
"strict": "error"
13+
}
14+
}

build/api.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env node
2+
'use strict'
3+
4+
const docgen = require('react-docgen-typescript')
5+
const fs = require('fs').promises
6+
const path = require('path')
7+
const globby = require('globby')
8+
9+
// These are the filetypes we only care about replacing the version
10+
const GLOB = ['src/components/**/*.tsx']
11+
const GLOBBY_OPTIONS = {
12+
cwd: path.join(__dirname, '..'),
13+
gitignore: true,
14+
ignore: ['**/__tests__/**'],
15+
}
16+
const EXCLUDED_FILES = []
17+
18+
const options = {
19+
savePropValueAsString: true,
20+
}
21+
22+
async function createMdx(filename, name, props) {
23+
if (typeof props === 'undefined') return
24+
25+
// let content = `### ${name}\n\n| Prop name | Description | Type |\n| --- | --- | --- |\n`
26+
let content = `| Prop name | Description | Type |\n| --- | --- | --- |\n`
27+
28+
for (const [key, value] of Object.entries(props).sort()) {
29+
if (value.parent.fileName !== 'react/node_modules/@types/react/index.d.ts') {
30+
content += `| ${value['name']} | ${value['description']} | ${value['type']['name']} |\n`
31+
console.log(`${key}: ${value}`)
32+
}
33+
}
34+
35+
await fs.writeFile(`api/${filename}.api.mdx`, content, { encoding: 'utf8' }).then(() => {
36+
// Do whatever you want to do.
37+
console.log('Done')
38+
})
39+
}
40+
41+
async function main() {
42+
try {
43+
const files = await globby(GLOB, GLOBBY_OPTIONS, EXCLUDED_FILES)
44+
45+
await Promise.all(
46+
files.map((file) => {
47+
const props = docgen.parse(file, options)
48+
if (props && typeof props[0] !== 'undefined') {
49+
const filename = path.basename(file, '.tsx')
50+
createMdx(filename, props[0].displayName, props[0].props)
51+
}
52+
// const props = docgen.parse(file, options)
53+
// if (props) console.log(props)
54+
}),
55+
)
56+
} catch (error) {
57+
console.error(error)
58+
process.exit(1)
59+
}
60+
}
61+
62+
main()

doczrc.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

gatsby-browse.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './src/styles/style.scss'

gatsby-config.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,42 @@
11
module.exports = {
22
siteMetadata: {
3-
siteUrl: `https://coreui.io/`,
3+
title: `CoreUI for React.js`,
4+
titleTemplate: '%s · React UI Components · CoreUI ',
5+
description: `CoreUI for React.js is UI Component library written in TypeScript, and ready for your next React.js project.`,
6+
url: `https://coreui.io/react/docs/`,
7+
image: '', // Path to your image you placed in the 'static' folder
8+
twitterUsername: '@coreui_io',
49
},
510
plugins: [
11+
{
12+
resolve: `gatsby-plugin-mdx`,
13+
options: {
14+
defaultLayouts: {
15+
docs: require.resolve('./src/docs/templates/Docs.tsx'),
16+
},
17+
gatsbyRemarkPlugins: [
18+
{
19+
// resolve: `gatsby-remark-embed-markdown`,
20+
resolve: require.resolve('./src/docs/plugins/gatsby-remark-embed-markdown'),
21+
options: {
22+
directory: `${__dirname}/api/`,
23+
},
24+
},
25+
{
26+
resolve: `gatsby-remark-autolink-headers`,
27+
},
28+
],
29+
},
30+
},
31+
{
32+
resolve: `gatsby-source-filesystem`,
33+
options: {
34+
name: `docs`,
35+
path: `${__dirname}/content/docs/`,
36+
},
37+
},
638
'gatsby-plugin-sass',
39+
'gatsby-plugin-typescript',
740
{
841
resolve: `gatsby-plugin-sitemap`,
942
options: {
@@ -19,5 +52,11 @@ module.exports = {
1952
],
2053
},
2154
},
55+
// {
56+
// resolve: `gatsby-transformer-remark`,
57+
// options: {
58+
// plugins: [`gatsby-remark-autolink-headers`],
59+
// },
60+
// },
2261
],
2362
}

gatsby-node.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
const path = require('path')
2+
const { createFilePath } = require('gatsby-source-filesystem')
3+
4+
exports.onCreateNode = ({ node, actions, getNode }) => {
5+
const { createNodeField } = actions
6+
7+
// you only want to operate on `Mdx` nodes. If you had content from a
8+
// remote CMS you could also check to see if the parent node was a
9+
// `File` node here
10+
if (node.internal.type === 'Mdx') {
11+
const value = createFilePath({ node, getNode })
12+
13+
createNodeField({
14+
// Name of the field you are adding
15+
name: 'slug',
16+
// Individual MDX node
17+
node,
18+
// Generated value based on filepath with "blog" prefix. you
19+
// don't need a separating "/" before the value because
20+
// createFilePath returns a path with the leading "/".
21+
value: `${value}`,
22+
})
23+
}
24+
}
25+
26+
exports.createPages = async ({ graphql, actions, reporter }) => {
27+
// Destructure the createPage function from the actions object
28+
const { createPage } = actions
29+
const result = await graphql(`
30+
query {
31+
allMdx {
32+
edges {
33+
node {
34+
id
35+
fields {
36+
slug
37+
}
38+
tableOfContents(maxDepth: 10)
39+
}
40+
}
41+
}
42+
}
43+
`)
44+
if (result.errors) {
45+
reporter.panicOnBuild('🚨 ERROR: Loading "createPages" query')
46+
}
47+
// Create blog post pages.
48+
const posts = result.data.allMdx.edges
49+
// you'll call `createPage` for each result
50+
posts.forEach(({ node }, index) => {
51+
createPage({
52+
// This is the slug you created before
53+
// (or `node.frontmatter.slug`)
54+
path: node.fields.slug,
55+
// This component will wrap our MDX content
56+
component: path.resolve(`./src/docs/templates/Docs.tsx`),
57+
// You can use the values in this context in
58+
// our page layout component
59+
context: { id: node.id },
60+
})
61+
})
62+
}

package.json

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"name": "@coreui/react",
3-
"version": "4.0.0-beta.5",
3+
"version": "4.0.0-beta.6",
4+
"config": {
5+
"version_short": "4.0"
6+
},
47
"description": "",
58
"license": "MIT",
69
"main": "dist/index.js",
@@ -9,13 +12,12 @@
912
"files": [
1013
"dist/",
1114
"src/",
12-
"doczrc.js",
1315
"tsconfig.json",
1416
"package.json"
1517
],
1618
"scripts": {
1719
"build": "rollup -c",
18-
"docs:dev": "docz dev",
20+
"docs:dev": "gatsby dev",
1921
"docs:build": "docz build",
2022
"lint": "eslint \"src/components/**/*.{js,ts,tsx}\"",
2123
"test": "jest --coverage",
@@ -28,49 +30,58 @@
2830
"react-router-dom": "^5.2.0"
2931
},
3032
"devDependencies": {
31-
"@babel/core": "^7.15.0",
32-
"@babel/preset-env": "^7.15.0",
33-
"@babel/preset-react": "^7.14.5",
3433
"@coreui/coreui": "^4.0.1",
3534
"@coreui/icons": "^2.0.1",
3635
"@coreui/icons-react": "^2.0.0-rc.5",
3736
"@coreui/react-chartjs": "^2.0.0-rc.1",
3837
"@emotion/react": "^11.4.1",
3938
"@emotion/styled": "^11.3.0",
39+
"@mdx-js/mdx": "^1.6.22",
40+
"@mdx-js/react": "^1.6.22",
4041
"@popperjs/core": "^2.9.3",
4142
"@rollup/plugin-commonjs": "^20.0.0",
4243
"@rollup/plugin-node-resolve": "^13.0.4",
4344
"@rollup/plugin-typescript": "^8.2.5",
4445
"@testing-library/jest-dom": "^5.14.1",
4546
"@testing-library/react": "^12.0.0",
46-
"@types/react": "^17.0.17",
47+
"@types/react": "^17.0.19",
4748
"@types/react-dom": "^17.0.9",
49+
"@types/react-helmet": "^6.1.2",
4850
"@types/react-transition-group": "^4.4.2",
49-
"@typescript-eslint/eslint-plugin": "^4.29.1",
50-
"@typescript-eslint/parser": "^4.29.1",
51+
"@typescript-eslint/eslint-plugin": "^4.29.2",
52+
"@typescript-eslint/parser": "^4.29.2",
5153
"classnames": "^2.3.1",
52-
"docz": "^2.3.1",
5354
"eslint": "^7.32.0",
5455
"eslint-config-prettier": "^8.3.0",
5556
"eslint-plugin-jsdoc": "^36.0.7",
5657
"eslint-plugin-prettier": "^3.4.0",
5758
"eslint-plugin-react": "^7.24.0",
5859
"eslint-plugin-react-hooks": "^4.2.0",
59-
"gatsby-plugin-google-gtag": "2",
60-
"gatsby-plugin-sass": "3",
61-
"gatsby-plugin-sitemap": "2",
60+
"gatsby": "^3.12.0",
61+
"gatsby-plugin-google-gtag": "3",
62+
"gatsby-plugin-mdx": "^2.12.0",
63+
"gatsby-plugin-sass": "4",
64+
"gatsby-plugin-sitemap": "4",
65+
"gatsby-remark-autolink-headers": "^4.9.0",
66+
"gatsby-remark-embed-markdown": "^0.0.4",
67+
"gatsby-source-filesystem": "^3.12.0",
68+
"gatsby-transformer-remark": "^4.9.0",
69+
"glob": "^7.1.7",
70+
"globby": "^11.0.4",
6271
"jest": "^27.0.6",
6372
"prettier": "^2.3.2",
73+
"prism-react-renderer": "^1.2.1",
74+
"prismjs": "^1.24.1",
6475
"react": "^17.0.1",
76+
"react-docgen-typescript": "^2.1.0",
6577
"react-dom": "^17.0.1",
6678
"react-helmet": "^6.1.0",
6779
"react-popper": "^2.2.5",
6880
"react-transition-group": "^4.4.2",
6981
"rollup": "^2.56.22.56.2",
7082
"rollup-plugin-peer-deps-external": "^2.2.4",
71-
"rollup-plugin-typescript2": "^0.30.0",
72-
"sass": "^1.37.5",
73-
"ts-jest": "^27.0.4",
83+
"sass": "^1.38.0",
84+
"ts-jest": "^27.0.5",
7485
"typescript": "^4.3.5"
7586
},
7687
"jest": {

public/images/angular.jpg

165 KB
Loading

public/images/vue.jpg

167 KB
Loading

public/page-data/4.0/components/button-group/page-data.json

Lines changed: 5 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)