Skip to content

Commit

Permalink
docs: refactor and switch to vitepress for performance and SEO (vexip…
Browse files Browse the repository at this point in the history
…-ui#308)

* wip: trensfer

* wip: transfer

* wip: split layout

* wip: transfer

* wip: transfer

* refactor(docs): split vite config

* chore: adjust config

* chore: update lock file

* wip: transfer

* fix(docs): fix not-found page display

* refactor: transfer demo markdown

* fix(docs): fix the demo display

* chore: add tag shortcut

* docs: display optimize

* fix: markdown style

* chore: add title tag style

* chore: adjust aside menu since logic

* docs: add since tag display

* docs: fix markdown match info rule

* wip: search component

* fix: homepage component button link

* wip: mobile sub header

* refactor: mobile sub header

* feat(utils): enhance flatTree to support depth first and filter

* chore: proofread and improve README.md [skip ci]

* fix(utils): correct flatTree filter method

* feat: add page-links component

* feat: add edit-link component

* feat: add lastTime display

* feat: search component add keyboard shortcut

* fix: repair ts error in vite.config

* feat: component docs add contributor display

* refactor: include contributors logic into component

* chore: add footer

* chore: optimize import order

* style: optimize mobile display

* build: ensure effective build

* chore: update

* wip: demo target

* fix: hash target for demo

* chore: imrpve search

* chore: improve guides

* wip: add footer links

* feat: add footer links

* chore: improve i18n

* chore: remove code

* fix: section off docs layout and demo styles

* docs: add i18n and ssr docs

* docs: add custom-form-control guide

* chore: update create script

* docs: add development guide

* chore: improve

* docs: optimize footer title display

* chore: update vitepress version

* fix: repair dark mode value

* docs: update markdown desc

* fix: homepage button link

* chore: ajust

* chore: remove useless files

* chore: remove useless files

* chore: remove useless meta json

* chore: check and clear

---------

Co-authored-by: winches <“[email protected]”>
Co-authored-by: winches <[email protected]>
  • Loading branch information
3 people authored May 24, 2023
1 parent ee639e3 commit 5f08a93
Show file tree
Hide file tree
Showing 1,597 changed files with 22,562 additions and 16,716 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ module.exports = {
files: ['docs/**'],
globals: {
__ROLLBACK_LANG__: 'readonly'
},
rules: {
'import/order': 'off'
}
},
{
Expand Down
3 changes: 3 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ Before submitting the PR, please make sure you do the following:
-->

### Description

<!-- Clear and concise description of what the PR is solving. -->

### Linked Issues

<!-- Fix #123. Fix #666. -->

### Additional Context

<!-- Any other context or screenshots about the PR here. -->
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
shell-emulator=true
shell-emulator=true
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"xsl"
],
"volar.inlayHints.eventArgumentInInlineHandlers": false,
"vue.inlayHints.inlineHandlerLeading": false,
"[vue]": {
"editor.defaultFormatter": "Vue.volar"
},
Expand Down
47 changes: 31 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,78 @@

First, thanks for being interested in contributing on this project!

## Development
## Pre-request

### Pre-request

Before starting, you should ensure your mechine is having:
Before starting, ensure your mechine is having:

Node >= 18

pnpm >= 8

### Setup
## Setup

Fork this repo, the clone it to your local mechine and intsall the dependencies:
Fork [Vexip UI](https://github.com/vexip-ui/vexip-ui) and clone to your local mechine and install dependencies:

```sh
pnpm install # pnpm i
```

Then you need to build all packages under `common`:
Then you need to build once the packages under `common` (**IMPORTANT**):

```sh
pnpm run build:common
```

### Developing for Component
## Component Development

We use a vite project in `dev-server` for development.
We use a Vite project in `dev-server` a development server.

Using the following command you can start development server for specify component:
You can use the following command to start development server for specify component:

```sh
pnpm run serve [component]
```

You can also specify the port and language via additional command:
After the server is successfully started, the demos of the components specified under `docs/demos` will be used as development cases.

The development server uses `8008` port and Chinese demos by default, you can add `-p` and `-l` parameters to the command to specify the port and language respectively:

```sh
pnpm run serve [component] -p [port] -l [languagt]
```

### Developing for Document
## Documentation Development

We alse use a vite project for documenting, you can start it locally:
We use [VitePress](https://vitepress.dev/) as the documentation framework. You can start it locally with the following command:

```sh
pnpm run serve:docs
```

## Create New Component

you can create some templete files by:
You can quickly create a new component using template files:

```sh
pnpm run create [component-name]
pnpm run create [component]
```

Then you need to update exports files by:
Wait patiently for the files to be created, then you can check the files in the following locations:

- `components/[component]/index.ts`
- `components/[component]/props.ts`
- `components/[component]/css.ts`
- `components/[component]/style.ts`
- `components/[component]/[component].vue`
- `components/[component]/tests/ssr.spec.tsx`
- `components/[component]/tests/[component].spec.tsx`
- `docs/demos/[component]/basis/demo.en-US.vue`
- `docs/demos/[component]/basis/demo.zh-CN.vue`
- `docs/en-US/component/[component].md`
- `docs/zh-CN/component/[component].md`
- `style/[component].scss`

After confirming, you can execute the bootstrap command and start developing the component and its documentation.

```sh
pnpm run bootstrap
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2019-present vexip-ui
Copyright (c) 2019-present vexip-ui and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
215 changes: 215 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
import { getPackageInfoSync, resolveModule } from 'local-pkg'
import { getGuideConfig } from './config/guide'
import { getComponentConfig } from './config/component'
import { highlight } from '../build/highlight'
import { markdownItSetup } from '../build/markdown'
import { toKebabCase } from '@vexip-ui/utils'
import * as compiler from '@vue/compiler-sfc'

import type { UserConfig } from 'vitepress'
import type { ThemeConfig } from './theme/types'

compiler.parseCache.max = 10000

export default <UserConfig<ThemeConfig>>{
srcExclude: ['demos', 'guides', 'README.md'],
ignoreDeadLinks: true,
titleTemplate: 'Vexip UI',
lastUpdated: true,
head: [
['meta', { 'http-equiv': 'Expires', content: '0' }],
['meta', { 'http-equiv': 'Pragma', content: 'no-cache' }],
['meta', { 'http-equiv': 'Cache', content: 'no-cache' }],
['meta', { 'http-equiv': 'Cache-control', content: 'no-store,no-cache,must-revalidate' }],
['link', { rel: 'icon', type: 'image/svg+xml', href: '/vexip-ui.svg' }]
],
markdown: {
highlight,
config: markdownItSetup
},
vue: {
template: {
ssr: true
},
compiler: compiler as any
},
themeConfig: {
/**
* 自定义配置信息
* asideMenus 侧边栏菜单
*/
asideMenus: getAsideMenus(),

nav: [
{ key: 'guides', i18n: 'common.guides', link: '/guide/vexip-ui', activeMatch: '/guide/' },
{
key: 'components',
i18n: 'common.components',
link: '/component/button',
activeMatch: '/component/'
},
{ key: 'playground', i18n: 'common.playground', link: 'https://playground.vexipui.com' }
],
outline: {
'/guide/': 2,
'/component/': 3
},
editLink: {
pattern: 'https://github.com/vexip-ui/vexip-ui/edit/main/docs/:path'
},

footerLinks: []
},
locales: {
'en-US': {
label: 'English',
lang: 'en-US',
themeConfig: {
footerLinks: getFooterLinks('en-US')
}
},
'zh-CN': {
label: '中文',
lang: 'zh-CN',
themeConfig: {
footerLinks: getFooterLinks('zh-CN')
}
}
}
}

let version: string | undefined

function queryLibVersion() {
if (version) return version

try {
version =
getPackageInfoSync('vexip-ui')?.version ??
getPackageInfoSync('vexip-ui', { paths: [resolveModule('vexip-ui') || process.cwd()] })
?.version
} catch (e) {
console.error(e)
}

if (!version) {
throw new Error('[vexip-ui:docs] failed to load vexip-ui version, please check')
}

return version
}

function getAsideMenus(): ThemeConfig['asideMenus'] {
const versionPrefix = queryLibVersion().split('.').slice(0, 2).join('.') + '.'

return {
'/guide/': getGuideConfig().map(group => {
return {
key: group.name,
i18n: `guide.${group.name}`,
items: group.guides.map(guide => {
return {
key: guide.name,
link: `/guide/${guide.name}`,
i18n: `guide.${guide.i18n}`
}
})
}
}),
'/component/': getComponentConfig().map(group => {
return {
key: group.name,
i18n: `group.${group.name}`,
count: true,
items: group.components.map(component => ({
key: component.name,
link: `/component/${toKebabCase(component.name)}`,
i18n: `component.${component.name}`,
tag: component.since?.startsWith(versionPrefix) ? 'New' : '',
origin: component.name
}))
}
})
}
}

function getFooterLinks(lang: 'zh-CN' | 'en-US'): ThemeConfig['footerLinks'] {
const t = (s: string) => `footer.${s}`

return [
{
i18n: t('resources'),
items: [
{
text: 'Vexip Nuxt Module',
link: 'https://github.com/vexip-ui/nuxt'
},
{
text: 'Vexip Lint Config',
subi18n: t('lintConfigSet'),
link: 'https://github.com/vexip-ui/lint-config'
},
{
text: 'Create Vexip',
subi18n: t('createProject'),
link: 'https://github.com/vexip-ui/create-vexip'
},
{
text: 'Grid Layout Plus',
subi18n: t('gridLayout'),
link: `https://grid-layout-plus.netlify.app/${lang === 'zh-CN' ? 'zh/' : ''}`
},
{
text: 'vite-plugin-dts',
link: 'https://github.com/qmhc/vite-plugin-dts'
},
{
text: 'vue-hooks-plus',
subi18n: t('hooksLib'),
link: `https://inhiblabcore.github.io/docs/hooks/${lang !== 'zh-CN' ? 'en/' : ''}`
},
{
text: 'Vexip SFC Playground',
link: 'https://playground.vexipui.com/'
},
{
text: 'RedBlues-1980',
subi18n: t('logoDesign'),
link: 'https://richuangangban1980.lofter.com/'
}
]
},
{
i18n: t('help'),
items: [
{
text: 'GitHub',
link: 'https://github.com/vexip-ui/vexip-ui'
},
{
i18n: t('changelog'),
link: 'https://github.com/vexip-ui/vexip-ui/blob/main/CHANGELOG.md'
},
{
i18n: t('issue'),
link: 'https://github.com/vexip-ui/vexip-ui/issues'
},
{
i18n: t('contribute'),
link: 'https://github.com/vexip-ui/vexip-ui/blob/main/CONTRIBUTING.md'
},
{
i18n: t('qqGroup'),
link: 'https://jq.qq.com/?_wv=1027&k=5KlA84xG'
},
{
i18n: t('sponsor'),
link:
lang === 'zh-CN'
? '/zh-CN/guide/vexip-ui.html#%E8%B4%A1%E7%8C%AE'
: '/en-US/guide/vexip-ui.html#contributing'
}
]
}
]
}
File renamed without changes.
34 changes: 34 additions & 0 deletions docs/.vitepress/config/guide.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export interface GuideConfig {
name: string,
i18n: string
}

export interface GuideGroup {
name: string,
guides: GuideConfig[]
}

export function getGuideConfig(): GuideGroup[] {
return [
{
name: 'introduction',
guides: [
{ name: 'vexip-ui', i18n: 'vexipui' },
{ name: 'getting-started', i18n: 'gettingStarted' },
{ name: 'name-origin', i18n: 'nameOrigin' },
{ name: 'logo-origin', i18n: 'logoOrigin' }
]
},
{
name: 'further',
guides: [
{ name: 'global-config', i18n: 'globalConfig' },
{ name: 'style-config', i18n: 'styleConfig' },
{ name: 'i18n', i18n: 'i18n' },
{ name: 'ssr', i18n: 'ssr' },
{ name: 'custom-form-control', i18n: 'customFormControl' },
{ name: 'development-guide', i18n: 'developmentGuide' }
]
}
]
}
Loading

0 comments on commit 5f08a93

Please sign in to comment.