Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 120,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "es5",
"singleAttributePerLine": false,
"bracketSameLine": true
}
929 changes: 917 additions & 12 deletions bun.lock

Large diffs are not rendered by default.

146 changes: 107 additions & 39 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,59 +1,127 @@
import { defineConfig } from 'vitepress'
import {
enConfig,
enSearch,
zhCNConfig,
zhCNSearch,
zhHKConfig,
zhHKSearch,
} from './locales'

// https://vitepress.dev/reference/site-config
// @ts-ignore
export default defineConfig(({ mode }) => {
return {
import { groupIconVitePlugin } from 'vitepress-plugin-group-icons'
import Unocss from 'unocss/vite'
import { markdownConfig } from './config/markdown'
import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { localesConfig } from './config/locales'
import { withMermaid } from 'vitepress-plugin-mermaid'
import { rewriteMarkdownPath } from './utils'
import * as cheerio from 'cheerio'

const insertScript = (html: string) => {
const $ = cheerio.load(html)
$('head').prepend(
`<script>window.__API_PROXY_URL__ = ${JSON.stringify(process.env.VITE_PORTAL_GATEWAY_BASE_URL)}</script>`,
`<script defer˝ src="https://assets.lbctrl.com/uploads/b63bb77e-74b5-43d3-8bf4-d610be91c838/longport-internal.iife.js"></script>`
)
return $.html()
}

export default defineConfig(
withMermaid({
title: 'PortAI Docs',
description: 'PortAI Documentation',
ignoreDeadLinks: true,
cleanUrls: true,
appearance: true,
lastUpdated: true,
cleanUrls: true,
metaChunk: true,
ignoreDeadLinks: true,
base: '/',

head: [
['link', { rel: 'icon', type: 'image/svg+xml', href: 'https://assets.lbkrs.com/uploads/f029efba-486b-4c32-8b05-1a87b0fb61f8/logo-without-title-lb.svg' }],
],

// Multi-language support
locales: {
en: enConfig,
'zh-CN': zhCNConfig,
'zh-HK': zhHKConfig,
srcExclude: ['README.md'],
rewrites: rewriteMarkdownPath,
markdown: markdownConfig,
transformHtml(code) {
return insertScript(code)
},

sitemap: {
hostname: 'https://open.longportapp.com',
transformItems(items) {
return items.filter((item) => !item.url.includes('migration'))
},
},

/* prettier-ignore */
head: [
['link', { rel: 'shortcut icon', type: 'image/x-icon', href: 'https://assets.lbkrs.com/uploads/f029efba-486b-4c32-8b05-1a87b0fb61f8/logo-without-title-lb.svg' }],
['meta', { name: 'theme-color', content: '#5f67ee' }],
['meta', { name: 'twitter:card', content: 'summary' }],
['meta', { name: 'twitter:site', content: 'https://open.longportapp.com' }],
['meta', { name: 'robots', content: 'index,follow' }],
['meta', { name: 'googlebot', content: 'index,follow' }],
['script', { async: '', src: 'https://www.googletagmanager.com/gtag/js?id=G-JNRX7GS04Y' }],
['script', {}, `window.dataLayer = window.dataLayer||[];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-JNRX7GS04Y');`],
['script', { defer: '', src: 'https://assets.lbkrs.com/pkg/sensorsdata/1.21.13.min.js' }],
['script', { async: '', src: 'https://at.alicdn.com/t/c/font_2621450_y740y72ffjq.js' }],
],
themeConfig: {
logo: {
src: 'https://assets.lbkrs.com/uploads/f029efba-486b-4c32-8b05-1a87b0fb61f8/logo-without-title-lb.svg',
width: 48,
height: 48,
},

footer: {
message: 'Released under the MIT License',
copyright: 'Copyright © 2025-present',
},

search: {
provider: 'local',
options: {
locales: {
...enSearch,
...zhCNSearch,
...zhHKSearch,
},
},

locales: localesConfig,

vite: {
ssr: {
noExternal: ['vue-i18n'],
},
server: {
port: 8000,
proxy: {
'/api': {
target: process.env.VITE_API_BASE_URL || 'https://openapi.longportapp.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
optimizeDeps: {
// Exclude vuetify since it has an issue with vite dev - TypeError: makeVExpansionPanelTextProps is not a function - the makeVExpansionPanelTextProps is used before it is defined
exclude: ['vuetify'],
},
build: {
chunkSizeWarningLimit: 1000,
},
resolve: {
alias: [
{
find: '@',
replacement: dirname(fileURLToPath(new URL('./theme', import.meta.url))),
},
{
find: '~',
replacement: dirname(fileURLToPath(new URL('../', import.meta.url))),
},
],
},
plugins: [
groupIconVitePlugin(),
Unocss({
configFile: '../unocss.config.ts',
}),

/**s
* see https://github.com/vuejs/vitepress/issues/3314
* 实际上仅会在开发者模式注入
*/
{
name: 'inject-extra-script',
transformIndexHtml(code) {
return insertScript(code)
},
},
],
},
}
})
})
)
22 changes: 22 additions & 0 deletions docs/.vitepress/config/locales.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { DefaultTheme, LocaleConfig } from 'vitepress'
import { enConfig } from '../locales/en'
import { zhCNConfig } from '../locales/zh-CN'
import { zhHKConfig } from '../locales/zh-HK'

export const localesConfig: LocaleConfig<DefaultTheme.Config> = {
en: {
label: 'English',
lang: 'en-US',
...enConfig,
},
'zh-CN': {
label: '简体中文',
lang: 'zh-CN',
...zhCNConfig,
},
'zh-HK': {
label: '繁體中文',
lang: 'zh-HK',
...zhHKConfig,
},
}
55 changes: 55 additions & 0 deletions docs/.vitepress/config/markdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { type MarkdownOptions } from 'vitepress'
import { groupIconMdPlugin } from 'vitepress-plugin-group-icons'
import { tipContainerPlugin } from '../md-plugins/tip-container'
import { GenTryItPlugin } from '../md-plugins/gen-try-it.ts'
import { NormalizeMdPlugin } from '../md-plugins/normalize-md'

export const markdownConfig: MarkdownOptions = {
image: {
lazyLoading: true,
},
math: true,
codeTransformers: [
// We use `[!!code` in demo to prevent transformation, here we revert it back.
{
postprocess(code) {
return code.replace(/\[\!\!code/g, '[!code')
},
},
],

config(md) {
const fence = md.renderer.rules.fence!
md.renderer.rules.fence = function (tokens, idx, options, env, self) {
const { localeIndex = 'root' } = env
const codeCopyButtonTitle = (() => {
switch (localeIndex) {
case 'es':
return 'Copiar código'
case 'fa':
return 'کپی کد'
case 'ko':
return '코드 복사'
case 'pt':
return 'Copiar código'
case 'ru':
return 'Скопировать код'
case 'zh-CN':
return '复制代码'
case 'zh-HK':
return '複製代碼'
default:
return 'Copy code'
}
})()
return fence(tokens, idx, options, env, self).replace(
'<button title="Copy Code" class="copy"></button>',
`<button title="${codeCopyButtonTitle}" class="copy"></button>`
)
}
md.use(NormalizeMdPlugin)
md.use(groupIconMdPlugin)
md.use(tipContainerPlugin)
md.use(GenTryItPlugin)
},
}
Loading