Skip to content

Commit 4e0a22c

Browse files
committed
docs: update theme
1 parent 741c9ac commit 4e0a22c

File tree

11 files changed

+459
-98
lines changed

11 files changed

+459
-98
lines changed

gatsby-config.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
2-
const pkg = require('./package.json')
2+
const pkg = require(`./package.json`)
33

44
module.exports = {
5+
pathPrefix: `react/docs/${pkg.config.version_short}/`,
56
siteMetadata: {
67
title: `CoreUI for React.js`,
7-
titleTemplate: '%s · React UI Components · CoreUI ',
8+
titleTemplate: `%s · React UI Components · CoreUI `,
89
description: `CoreUI for React.js is UI Component library written in TypeScript, and ready for your next React.js project.`,
910
url: `https://coreui.io/react/docs/${pkg.config.version_short}/`,
10-
image: '', // Path to your image you placed in the 'static' folder
11-
twitterUsername: '@coreui_io',
11+
siteUrl: `https://coreui.io/react/docs/${pkg.config.version_short}/`,
12+
image: ``, // Path to your image you placed in the `static` folder
13+
twitterUsername: `@coreui_io`,
1214
},
1315
plugins: [
16+
{
17+
resolve: `gatsby-plugin-manifest`,
18+
options: {
19+
icon: `${__dirname}/src/docs/assets/images/brand/icon.png`,
20+
name: `CoreUI for React.js`,
21+
short_name: `CoreUI for React.js`,
22+
start_url: `https://coreui.io/react/`,
23+
background_color: `#fff`,
24+
theme_color: `#321fdb`,
25+
display: `standalone`,
26+
},
27+
},
1428
{
1529
resolve: `gatsby-plugin-mdx`,
1630
options: {
1731
defaultLayouts: {
18-
docs: require.resolve('./src/docs/templates/Docs.tsx'),
32+
docs: require.resolve(`./src/docs/templates/Docs.tsx`),
1933
},
2034
gatsbyRemarkPlugins: [
2135
{
22-
resolve: require.resolve('./src/docs/plugins/gatsby-remark-embed-markdown'),
36+
resolve: require.resolve(`./src/docs/plugins/gatsby-remark-embed-markdown`),
2337
options: {
2438
directory: `${__dirname}/docs/${pkg.config.version_short}/api/`,
2539
},
@@ -39,11 +53,11 @@ module.exports = {
3953
resolve: `gatsby-source-filesystem`,
4054
options: {
4155
name: `docs`,
42-
path: `${__dirname}/docs/`,
56+
path: `${__dirname}/docs/${pkg.config.version_short}/`,
4357
},
4458
},
45-
'gatsby-plugin-sass',
46-
'gatsby-plugin-typescript',
59+
`gatsby-plugin-sass`,
60+
`gatsby-plugin-typescript`,
4761
{
4862
resolve: `gatsby-plugin-sitemap`,
4963
options: {
@@ -55,7 +69,7 @@ module.exports = {
5569
options: {
5670
// You can add multiple tracking ids and a pageview event will be fired for all of them.
5771
trackingIds: [
58-
'UA-118965717-1', // Google Analytics / GA
72+
`UA-118965717-1`, // Google Analytics / GA
5973
],
6074
},
6175
},

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"scripts": {
1919
"build": "rollup -c",
2020
"docs:api": "rimraf \"content/docs/$npm_package_config_version_short/api/*\" & node build/api.js",
21-
"docs:build": "run-s docs:api gatsby build",
21+
"docs:build": "gatsby build --prefix-paths",
22+
"docs:dist": "run-s docs:api docs:build",
2223
"docs:dev": "gatsby develop",
2324
"docs:serve": "gatsby serve",
2425
"lint": "eslint \"src/components/**/*.{js,ts,tsx}\"",
@@ -61,6 +62,7 @@
6162
"eslint-plugin-react-hooks": "^4.2.0",
6263
"gatsby": "^3.12.0",
6364
"gatsby-plugin-google-gtag": "3",
65+
"gatsby-plugin-manifest": "^3.12.0",
6466
"gatsby-plugin-mdx": "^2.12.0",
6567
"gatsby-plugin-sass": "4",
6668
"gatsby-plugin-sitemap": "4",

src/docs/components/Footer.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ const Footer: FC = ({ ...props }) => {
1717
<li className="d-inline-block ms-3">
1818
<a href="https://community.coreui.io/">Community</a>
1919
</li>
20+
<li className="d-inline-block ms-3 ps-3 border-start border-2">
21+
<a href="https://coreui.io/">CoreUI (Vanilla)</a>
22+
</li>
23+
<li className="d-inline-block ms-3">
24+
<a href="https://coreui.io/angular/">CoreUI for Angular</a>
25+
</li>
26+
<li className="d-inline-block ms-3">
27+
<a href="https://coreui.io/vue/">CoreUI for Vue.js</a>
28+
</li>
2029
</ul>
21-
<p className="mb-0">
22-
CoreUI is designed as the extension of <a href="https://getbootstrap.com">Bootstrap</a>.
23-
Special thanks for{' '}
24-
<a href="https://getbootstrap.com/docs/5.0/about/team/">Bootstrap team</a> and{' '}
25-
<a href="https://github.com/twbs/bootstrap/graphs/contributors">
26-
Bootstrap&#39;s contributors
27-
</a>
28-
.
29-
</p>
30+
<p className="mb-0">CoreUI for React is Open Source UI Components Library for React.</p>
3031
<p className="mb-0">
3132
Currently v{pkg.version}. Code licensed{' '}
3233
<a

src/docs/components/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const Header: FC = ({ ...props }) => {
2929
<CButton
3030
className="d-lg-inline-block my-2 my-md-0 ms-md-3"
3131
color="primary"
32-
href="#"
32+
href="https://coreui.io/react/#compare"
3333
variant="outline"
3434
>
3535
<CIcon icon={cilCloudDownload} /> Download

src/docs/components/Sidebar.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { FC } from 'react'
2+
import PropTypes from 'prop-types'
23

34
import { CSidebar, CSidebarBrand, CImage } from '../../index'
45
import { SidebarNav } from '.'
@@ -8,7 +9,11 @@ import { myContext } from './../templates/Docs'
89
import items from './../nav'
910
import logo from './../assets/coreui-react.svg'
1011

11-
const Sidebar: FC = ({ ...props }) => {
12+
interface SidebarProps {
13+
currentRoute: string
14+
}
15+
16+
const Sidebar: FC<SidebarProps> = ({ ...props }) => {
1217
return (
1318
<myContext.Consumer>
1419
{(context) => (
@@ -22,13 +27,17 @@ const Sidebar: FC = ({ ...props }) => {
2227
<CSidebarBrand className="justify-content-start ps-3">
2328
<CImage className="d-block mt-4 mb-5" src={logo} height={50} />
2429
</CSidebarBrand>
25-
<SidebarNav items={items} />
30+
<SidebarNav items={items} currentRoute={props.currentRoute} />
2631
</CSidebar>
2732
)}
2833
</myContext.Consumer>
2934
)
3035
}
3136

37+
Sidebar.propTypes = {
38+
currentRoute: PropTypes.string.isRequired,
39+
}
40+
3241
Sidebar.displayName = 'Sidebar'
3342

3443
export default Sidebar

src/docs/components/SidebarNav.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export type Badge = {
1111
}
1212

1313
export type NavItem = {
14-
component: string | ElementType
1514
name: string | JSX.Element
1615
icon?: string | JSX.Element
1716
badge?: Badge
@@ -21,9 +20,10 @@ export type NavItem = {
2120

2221
interface SidebarNavProps {
2322
items: NavItem[]
23+
currentRoute: string
2424
}
2525

26-
export const SidebarNav = ({ items }: SidebarNavProps) => {
26+
export const SidebarNav = ({ items, currentRoute }: SidebarNavProps) => {
2727
const navLink = (name: string | JSX.Element, icon: string | ReactNode, badge?: Badge) => {
2828
return (
2929
<>
@@ -52,7 +52,7 @@ export const SidebarNav = ({ items }: SidebarNavProps) => {
5252
<CNavGroup
5353
compact
5454
toggler={navLink(name, icon)}
55-
visible={location.pathname.startsWith(to)}
55+
visible={to.startsWith(currentRoute)}
5656
idx={String(index)}
5757
key={index}
5858
{...rest}
@@ -76,4 +76,5 @@ export const SidebarNav = ({ items }: SidebarNavProps) => {
7676

7777
SidebarNav.propTypes = {
7878
items: PropTypes.arrayOf(PropTypes.any).isRequired,
79+
currentRoute: PropTypes.string.isRequired,
7980
}

src/docs/components/Toc.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@ const Toc: FC = (props) => {
55
const { items } = props
66

77
const toc = (items) => {
8-
return items.map((item, index) => {
9-
if (Array.isArray(item.items)) {
8+
return (
9+
items &&
10+
items.map((item, index) => {
11+
if (Array.isArray(item.items)) {
12+
return (
13+
<li key={index}>
14+
<a href={item.url}>{item.title}</a>
15+
<ul>{toc(item.items)}</ul>
16+
</li>
17+
)
18+
}
1019
return (
1120
<li key={index}>
1221
<a href={item.url}>{item.title}</a>
13-
<ul>{toc(item.items)}</ul>
1422
</li>
1523
)
16-
}
17-
return (
18-
<li key={index}>
19-
<a href={item.url}>{item.title}</a>
20-
</li>
21-
)
22-
})
24+
})
25+
)
2326
}
2427

2528
return (

0 commit comments

Comments
 (0)