6944652966
mirror-to-gitee / mirror (push) Successful in 3s
原先导航「官方文档」指向 /#docs(首页内的文档区块), 用户期望点它直接进 http://open.5iot.com:5051/docs/。 改动 - 导航项改为外链 http://open.5iot.com:5051/docs/, 带 target=_blank 与 rel=noopener,新开标签页不打断阅读 - 首页 hero 的「官方文档」按钮同样改为外链直跳 - 文档站地址收敛为单一来源:data/content.ts 导出 DOCS_BASE / DOCS_HOME, 可用环境变量 DOCS_BASE 覆盖;config.mts 与 HomePage.vue 都引用它, 消除原先三处硬编码 - 首页的「官方文档」区块(#docs)保留,仍是各手册入口的聚合卡片 验证 - 导航渲染实测:href=http://open.5iot.com:5051/docs/, target=_blank - 点击实测:新开标签页到目标地址,原页面 URL 不变 - 锚点项高亮不受影响(点「产品功能」仍正常变蓝) - 构建 13 页 262 引用 0 失效
139 lines
4.4 KiB
TypeScript
139 lines
4.4 KiB
TypeScript
import { defineConfig } from 'vitepress'
|
|
import { projects } from '../data/projects'
|
|
import { docs, DOCS_HOME } from '../data/content'
|
|
|
|
/**
|
|
* 门户站构建配置
|
|
*
|
|
* SITE_BASE 由构建参数注入:
|
|
* - /www/ 过渡形态:挂在已有网关的 /www/ 路径下(没有独立域名时用)
|
|
* - / 独立域名形态:站点独占域名根路径
|
|
* 两者内容完全同源,只有资源前缀与路由前缀不同,所以用构建参数而不是改代码。
|
|
*/
|
|
const SITE_BASE = process.env.SITE_BASE ?? '/www/'
|
|
|
|
/** 代码仓组织(雪羊科技企业仓) */
|
|
const ORG_URL = process.env.ORG_URL ?? 'https://gitee.com/snowgoat'
|
|
|
|
/** 各项目的文档站地址(按项目 id 覆盖) */
|
|
const DOCS_URL: Record<string, string> = {
|
|
iotlcm: 'http://open.5iot.com:5051/docs/',
|
|
}
|
|
|
|
function tokenizeSearchText(text: string): string[] {
|
|
const terms = text.match(/[A-Za-z0-9]+|[\u3400-\u9fff]+/g) ?? []
|
|
return terms.flatMap((term) => {
|
|
if (!/^[\u3400-\u9fff]+$/.test(term)) return [term.toLowerCase()]
|
|
if (term.length === 1) return [term]
|
|
return Array.from({ length: term.length - 1 }, (_, index) => term.slice(index, index + 2))
|
|
})
|
|
}
|
|
|
|
const searchTranslations = {
|
|
button: {
|
|
buttonText: '搜索',
|
|
buttonAriaLabel: '搜索文档',
|
|
},
|
|
modal: {
|
|
displayDetails: '显示详细结果',
|
|
resetButtonTitle: '清除搜索',
|
|
backButtonTitle: '关闭搜索',
|
|
noResultsText: '没有找到相关结果',
|
|
footer: {
|
|
selectText: '选择',
|
|
selectKeyAriaLabel: '回车',
|
|
navigateText: '切换结果',
|
|
navigateUpKeyAriaLabel: '上箭头',
|
|
navigateDownKeyAriaLabel: '下箭头',
|
|
closeText: '关闭',
|
|
closeKeyAriaLabel: '退出',
|
|
},
|
|
},
|
|
}
|
|
|
|
export default defineConfig({
|
|
srcDir: './pages',
|
|
base: SITE_BASE,
|
|
title: '雪羊科技物联网卡与设备管理平台',
|
|
description: '雪羊科技开源的物联网卡与设备管理平台:物联网卡管理、DTU 设备管理、中后台开发框架,Apache-2.0 许可',
|
|
lang: 'zh-CN',
|
|
cleanUrls: true,
|
|
lastUpdated: false,
|
|
head: [
|
|
['link', { rel: 'icon', type: 'image/svg+xml', href: `${SITE_BASE}favicon.svg` }],
|
|
],
|
|
themeConfig: {
|
|
siteTitle: '雪羊科技<span class="site-subtitle">物联网卡与设备管理平台</span>',
|
|
logo: { src: '/snowgoat-logo.png', alt: '雪羊科技' },
|
|
nav: [
|
|
{ text: '首页', link: '/' },
|
|
{ text: '产品功能', link: '/#features' },
|
|
{ text: '核心能力', link: '/#core' },
|
|
{ text: '界面预览', link: '/#preview' },
|
|
// activeMatch:进入任一项目详情页时「项目」保持高亮
|
|
{ text: '项目', link: '/projects/', activeMatch: '^/projects/' },
|
|
// 官方文档直接跳文档站(外站),不在本站内做锚点停留
|
|
{
|
|
text: '官方文档',
|
|
link: DOCS_HOME,
|
|
target: '_blank',
|
|
rel: 'noopener',
|
|
},
|
|
{ text: '关于', link: '/about' },
|
|
],
|
|
sidebar: {
|
|
'/projects/': [
|
|
{
|
|
text: '项目',
|
|
collapsed: false,
|
|
items: projects.map((p) => ({ text: p.name, link: p.page })),
|
|
},
|
|
],
|
|
'/guide/': [
|
|
{
|
|
text: '门户',
|
|
collapsed: false,
|
|
items: [{ text: '门户部署', link: '/guide/portal-deploy' }],
|
|
},
|
|
],
|
|
},
|
|
socialLinks: [
|
|
{ icon: 'github', link: ORG_URL },
|
|
],
|
|
footer: {
|
|
message: '雪羊科技物联网卡与设备管理平台 · Apache-2.0',
|
|
copyright: 'Copyright © 雪羊科技',
|
|
},
|
|
search: {
|
|
provider: 'local',
|
|
options: {
|
|
translations: searchTranslations,
|
|
miniSearch: {
|
|
options: { tokenize: tokenizeSearchText },
|
|
searchOptions: { combineWith: 'AND' },
|
|
},
|
|
_render(src, env, md) {
|
|
const html = md.render(src, env)
|
|
if (env.relativePath !== 'index.md') return html
|
|
|
|
const homeSearchText = [
|
|
'雪羊科技开源 首页 项目 产品功能 核心能力 界面预览 官方文档',
|
|
...projects.map((project) => `${project.name} ${project.tagline} ${project.summary}`),
|
|
...docs.map((doc) => `${doc.name} ${doc.desc} ${doc.project}`),
|
|
].join('\n\n')
|
|
|
|
return `${html}\n${md.render(homeSearchText, env)}`
|
|
},
|
|
},
|
|
},
|
|
outline: {
|
|
level: [2, 3],
|
|
label: '本页目录',
|
|
},
|
|
docFooter: {
|
|
prev: '上一页',
|
|
next: '下一页',
|
|
},
|
|
},
|
|
})
|