Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
node-version: ${{ matrix.node-version }}
# yarn.lock is gitignored in this repo, so there is no lockfile to pin
# against or to key a cache on — install resolves from package.json.
- run: yarn install
- run: yarn install --ignore-engines
- run: yarn lib:build
- run: yarn lib:test

Expand All @@ -40,5 +40,5 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 22.x
- run: yarn install
- run: yarn install --ignore-engines
- run: yarn lint
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ Thumbs.db
*.swp
*.vi
*.zip
*~
*~
.gstack/
8 changes: 0 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,5 @@
"npm-run-all": "^4.1.5",
"prettier": "^3.8.4",
"typescript-eslint": "^8.61.0"
},
"overrides": {
"gatsby-remark-external-links": {
"unist-util-find": "1.0.2"
}
},
"resolutions": {
"**/gatsby-remark-external-links/unist-util-find": "1.0.2"
}
}
3 changes: 3 additions & 0 deletions packages/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
.astro/
43 changes: 43 additions & 0 deletions packages/docs/api.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Components to document. The @coreui/astro-docs-api-generator CLI (`yarn api`) runs
// the React extractor (react-docgen-typescript) and writes one <Name>.api.json per
// component into outDir — the shared ApiData shape the engine's <Api> renders. The
// list is scanned from source (every `C*.tsx` that isn't a test); extra entries are
// harmless (a page only imports the JSON it references).
import { readdirSync } from 'node:fs'
import { join, dirname, basename, relative } from 'node:path'
import { fileURLToPath } from 'node:url'

const here = dirname(fileURLToPath(import.meta.url))
const ROOTS = [
'../coreui-react/src/components',
'../coreui-react-chartjs/src',
'../coreui-icons-react/src',
]

const isComponent = (name) => /^C[A-Z].*\.tsx$/.test(name) && !/\.(d|spec|test)\.tsx$/.test(name)

function scan(dir, out) {
let entries
try {
entries = readdirSync(dir, { withFileTypes: true })
} catch {
return out
}
for (const e of entries) {
if (e.name === '__tests__' || e.name.startsWith('.')) continue
const p = join(dir, e.name)
if (e.isDirectory()) scan(p, out)
else if (isComponent(e.name)) out[basename(e.name, '.tsx')] = `./${relative(here, p)}`
}
return out
}

const components = {}
for (const root of ROOTS) scan(join(here, root), components)

export default {
framework: 'react',
outDir: 'src/api',
importPackage: '@coreui/react',
components,
}
45 changes: 45 additions & 0 deletions packages/docs/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { defineConfig } from 'astro/config'
import react from '@astrojs/react'
import mdx from '@astrojs/mdx'
import { coreuiDocs } from '@coreui/astro-docs/integration'
import { fileURLToPath } from 'node:url'
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)

// Live-src: point @coreui/react and its icon/chart submodules at their source in this
// repo. The icon data set (@coreui/icons) and chart.js stay published deps.
const reactSrc = fileURLToPath(new URL('../coreui-react/src/index.ts', import.meta.url))
const iconsReactSrc = fileURLToPath(new URL('../coreui-icons-react/src/index.ts', import.meta.url))
const reactChartjsSrc = fileURLToPath(new URL('../coreui-react-chartjs/src/index.ts', import.meta.url))
// @coreui/chartjs ships CJS `main` + a separate esm build; point imports at the esm
// so the named `customTooltips` export resolves under SSR.
const chartjsEsm = require.resolve('@coreui/chartjs/dist/js/coreui-chartjs.esm.js')
// Depth-independent imports for example + generated API data, so docs pages can
// move freely without rewriting relative paths.
const examples = fileURLToPath(new URL('./src/examples', import.meta.url))
const api = fileURLToPath(new URL('./src/api', import.meta.url))

export default defineConfig({
// Publish URL (site + base) is config-driven: coreuiDocs() reads `seo.url` from
// src/data/config.yml and sets Astro's `site` + `base` from it, so the versioned
// (…/react/docs/5.x) and current (…/react/docs) builds differ by one config value.
// coreuiDocs() detects the edition + wires styling; it returns an array (incl.
// global component auto-import), so spread it — and place it before mdx().
integrations: [react(), ...coreuiDocs(), mdx()],
vite: {
resolve: {
// Array form: the icons-react `/src/index` subpath import must match before the
// bare `@coreui/icons-react` entry.
alias: [
{ find: '@coreui/icons-react/src/index', replacement: iconsReactSrc },
{ find: '@coreui/icons-react', replacement: iconsReactSrc },
{ find: '@coreui/react-chartjs', replacement: reactChartjsSrc },
{ find: '@coreui/chartjs', replacement: chartjsEsm },
{ find: '@coreui/react', replacement: reactSrc },
{ find: '@examples', replacement: examples },
{ find: '@api', replacement: api },
],
},
},
})
Loading
Loading