Skip to content

Commit

Permalink
Use VitePress (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Dec 20, 2024
1 parent bb75fd5 commit f365ebb
Show file tree
Hide file tree
Showing 91 changed files with 7,062 additions and 16,242 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict'
'use strict';

module.exports = require('./eslint/eslint-config.js')
module.exports = require('./eslint/eslint-config.js');
2 changes: 0 additions & 2 deletions .github/workflows/GHPages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18
- name: Install Packages
run: |+
npm ci
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/NodeCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18
- name: Install Packages
run: |+
npm ci
Expand All @@ -27,8 +25,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18
- name: Install Packages
run: |+
npm ci
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/NpmPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
- name: setup Node
uses: actions/setup-node@v2
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- name: Install Packages
run: |+
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ packages/*/report
/lerna-debug.log
*npm-debug.log
packages/cheetah-grid-icon-svg-loader/.nyc_output/
packages/docs/.vuepress/public/dev
packages/docs/public/dev
packages/docs/.vitepress/cache
packages/cheetah-grid/dist-ts
packages/demo/.devdocs
/docs/assets
Expand Down
3 changes: 3 additions & 0 deletions packages/docs/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

!/.vitepress/
/.vitepress/cache/
4 changes: 4 additions & 0 deletions packages/docs/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 2,
"useTabs": false
}
147 changes: 147 additions & 0 deletions packages/docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import fs from 'fs'
import path from 'path'
import semver from 'semver'
import { defineConfig } from 'vitepress'
import { extractLinks } from './lib/sidebar-links.mjs'

const __dirname = path.dirname(new URL(import.meta.url).pathname)
const repoUrl = 'https://github.com/future-architect/cheetah-grid'

const extracted = extractLinks()
/** @type {import("vitepress").DefaultTheme.Sidebar} */
const links = extracted.items

const pkg = requireJson('../../cheetah-grid/package.json')

function resolve (dir) {
const p = path.join(__dirname, dir)
return p
}
function devPath (basePath) {
const rootPath = resolve(basePath)
const pkg = requireJson(path.join(rootPath, 'package.json'))
const p = path.join(rootPath, pkg.unpkg || pkg.main)
return p
}

function requireJson (jsonPath) {
const p = path.isAbsolute(jsonPath) ? jsonPath : resolve(jsonPath)
return JSON.parse(fs.readFileSync(p, 'utf8'))
}

export default async ({ mode }) => {
const production = mode === 'production'
const scriptPaths = []
const devDir = resolve('../public/dev')
if (production) {
const gridVersion = `${semver.major(pkg.version)}.${semver.minor(pkg.version)}.0-0`
const fallbackVersion = semver.minor(pkg.version) === 0 ? `${semver.major(pkg.version) - 1}` : `${semver.major(pkg.version)}.${semver.minor(pkg.version) - 1}.0`
const v = `^${gridVersion}||^${fallbackVersion}`
scriptPaths.push(
`https://unpkg.com/cheetah-grid@${v}`
)
} else {
if (!fs.existsSync(devDir)) {
fs.mkdirSync(devDir)
}
for (const p of [
devPath('../../cheetah-grid/')
]) {
const jsname = path.basename(p)
const dest = path.join(devDir, jsname)
fs.copyFileSync(p, dest)
scriptPaths.push(`/cheetah-grid/documents/dev/${jsname}`)
}
}
return defineConfig({
title: 'Cheetah Grid',
description: 'Cheetah Grid is the fastest open-source data table for web.',
outDir: resolve('../../../docs/documents'),
ignoreDeadLinks: 'localhostLinks',
markdown: {
lineNumbers: true,
config (md) { }
},
vite: {
resolve: {
alias: {
vue: resolve('../node_modules/vue/')
}
}
},
locales: {
root: {
lang: 'ja'
}
},
head: [
[
'link',
{
rel: 'icon',
href: '/cheetah-grid/documents/icon_512x512.svg',
type: 'image/svg+xml'
}
],
['link', { rel: 'stylesheet', href: 'https://fonts.googleapis.com/icon?family=Material+Icons' }],
['link', { rel: 'stylesheet', href: 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' }],

...scriptPaths.map(p => ['script', { src: p }])
],
base: '/cheetah-grid/documents/',
themeConfig: {
logo: '/logo.svg',
footer: {
copyright: `©2015 - ${new Date().getFullYear()} Future Corporation. Author Yosuke Ota. Code licensed under the MIT License.`
},
search: {
provider: 'local',
options: {
detailedView: true
}
},
editLink: {
pattern: `${repoUrl}/edit/master/packages/docs/:path`
},
outline: {
level: 'deep'
},
nav: [
{
text: 'Introduction',
link: '/introduction/'
},
{
text: 'API',
items: [
{
text: 'for JavaScript',
link: '/api/js/'
},
{
text: 'for Vue.js',
link: '/api/vue/'
},
{
text: 'for React',
link: 'https://github.com/future-architect/cheetah-grid/tree/master/packages/react-cheetah-grid#readme'
}
]
},
{
text: 'Demo',
link: 'https://future-architect.github.io/cheetah-grid/'
}
],

sidebar: links,

socialLinks: [
{
icon: 'github',
link: repoUrl
}
]
}
})
}
Loading

0 comments on commit f365ebb

Please sign in to comment.