9cd518227d
实测发现两个问题,均导致线上 404: 1. favicon 不生效 favicon.svg 放在 website/public/,但 srcDir 是 ./pages, VitePress 的 public 目录相对 srcDir 解析,即应为 pages/public/。 原位置不被打包,每个页面的 /www/favicon.svg 全部 404。 → 移到 website/pages/public/favicon.svg 2. 「文档中心」导航链接 404 DOCS_URL 默认 '/docs/',VitePress 会给站内链接自动加 base 前缀, 实际渲染成 '/www/docs/',而网关没有这个路径(文档站在 /docs/)。 → 默认值改为完整 URL,VitePress 判定为外链不做前缀拼接 验证(SITE_BASE=/www/ 与 / 两形态) - 页面引用完整性:146 → 139 条,失效 15 → 0 - HTTP 实测(模拟 nginx alias + try_files):8 页 200、 CSS/JS/favicon 200、/www 301、不存在页 404
84 lines
2.7 KiB
TypeScript
84 lines
2.7 KiB
TypeScript
import { defineConfig } from 'vitepress'
|
||
|
||
/**
|
||
* 官网(开源版门户站)构建配置
|
||
*
|
||
* SITE_BASE 由构建参数注入:
|
||
* - /www/ 过渡形态:挂在统一网关的 /www/ 路径下(没有独立域名时用)
|
||
* - / 独立域名形态:站点独占域名根路径
|
||
* 两者内容完全同源,差别只有资源前缀与路由前缀,所以用构建参数而不是改代码。
|
||
*/
|
||
const SITE_BASE = process.env.SITE_BASE ?? '/www/'
|
||
|
||
/**
|
||
* 仓库地址。开源版代码只发 git.5iot.com/iotlcm-public,
|
||
* 若后续确认了公开镜像站,改这一处即可(页面里统一引用常量,不重复硬编码)。
|
||
*/
|
||
const REPO_URL = process.env.REPO_URL ?? 'https://git.5iot.com/iotlcm-public/iotlcm'
|
||
|
||
/**
|
||
* 文档站地址。文档站与官网是两个容器,由网关按路径分流:
|
||
* - 官网在 /www/ 下,文档站在 /docs/ 下,两者同级
|
||
*
|
||
* 注意:VitePress 会给所有站内链接自动加上 base 前缀,'/docs/' 会被拼成
|
||
* '/www/docs/'——而网关并没有这个路径,点击「文档中心」会 404。
|
||
* 因此默认值必须是完整 URL(VitePress 判定为外链,不做前缀拼接)。
|
||
* 独立部署时用 DOCS_URL 覆盖成实际地址。
|
||
*/
|
||
const DOCS_URL = process.env.DOCS_URL ?? 'http://open.5iot.com:5051/docs/'
|
||
|
||
export default defineConfig({
|
||
srcDir: './pages',
|
||
base: SITE_BASE,
|
||
title: 'iotLCM',
|
||
description: 'iotLCM 物联网卡全生命周期管理平台(开源版)',
|
||
lang: 'zh-CN',
|
||
cleanUrls: true,
|
||
lastUpdated: false,
|
||
head: [
|
||
['link', { rel: 'icon', type: 'image/svg+xml', href: `${SITE_BASE}favicon.svg` }],
|
||
],
|
||
themeConfig: {
|
||
nav: [
|
||
{ text: '首页', link: '/' },
|
||
{ text: '功能', link: '/features' },
|
||
{ text: '方案对比', link: '/compare' },
|
||
{ text: '快速开始', link: '/guide/quickstart' },
|
||
{ text: '教程', link: '/guide/tutorial' },
|
||
{ text: '社区', link: '/community' },
|
||
{ text: '文档中心', link: DOCS_URL },
|
||
],
|
||
sidebar: {
|
||
'/guide/': [
|
||
{
|
||
text: '指南',
|
||
collapsed: false,
|
||
items: [
|
||
{ text: '快速开始', link: '/guide/quickstart' },
|
||
{ text: '部署与运维', link: '/guide/deploy' },
|
||
{ text: '教程视频', link: '/guide/tutorial' },
|
||
],
|
||
},
|
||
],
|
||
},
|
||
socialLinks: [
|
||
{ icon: 'github', link: REPO_URL },
|
||
],
|
||
footer: {
|
||
message: 'iotLCM 开源版 · Apache-2.0',
|
||
copyright: 'Copyright © iotLCM',
|
||
},
|
||
search: {
|
||
provider: 'local',
|
||
},
|
||
outline: {
|
||
level: [2, 3],
|
||
label: '本页目录',
|
||
},
|
||
docFooter: {
|
||
prev: '上一页',
|
||
next: '下一页',
|
||
},
|
||
},
|
||
})
|