fix(website-docs): serve everything but the homepage from /docs/

The site is deployed behind an upstream router that forwards only `/` and
`/docs/`. The homepage export also claimed /_next/, /brand/, /brands/,
/product/, /favicon.ico and Next's root RSC payloads, so behind that router
the page loaded without its scripts, styles or images.

Next's assetPrefix and the homepage's public assets now live under
/docs/_home/ (one `homeAssets` constant shared with the docs header), the
favicon reuses /docs/favicon.ico, and build-site.mjs leaves only index.html,
404.html and docs/ at the root. The homepage logo links are plain anchors
because <Link> navigation fetches RSC payloads from the root. check-site.mjs
now fails the build if a page references anything outside `/` and `/docs/`
or if anything else appears at the site root.
main
wizardchen 2026-09-24 15:15:22 +08:00 committed by lyingbug
parent 3e8b0bfc80
commit cee697920e
62 changed files with 63 additions and 27 deletions

View File

@ -2,7 +2,7 @@
import { computed, h, ref, watch, onMounted, onUnmounted } from 'vue'
import { useData, useRoute } from 'vitepress'
import Search from 'vitepress/dist/client/theme-default/components/VPNavBarSearch.vue'
import { repositoryUrl, headerIcons } from '../../shared/header'
import { repositoryUrl, headerIcons, homeAssets } from '../../shared/header'
const { isDark } = useData()
const route = useRoute()
const docsNavigation = [
@ -29,7 +29,7 @@ onUnmounted(() => document.removeEventListener('keydown', closeMenu))
<template>
<header class="wk-header wk-docs-header">
<div class="wk-header-inner">
<a class="wk-brand" href="/" target="_self" aria-label="WeKnora 首页"><span class="wk-logo"><img :src="'/brand/weknora-original.png'" alt="WeKnora" width="945" height="650"></span></a>
<a class="wk-brand" href="/" target="_self" aria-label="WeKnora 首页"><span class="wk-logo"><img :src="`${homeAssets}/brand/weknora-original.png`" alt="WeKnora" width="945" height="650"></span></a>
<nav id="main-navigation" class="wk-navigation" :class="{ 'is-open': open }" aria-label="文档导航">
<a v-for="item in docsNavigation" :key="item.href" :href="item.href" :aria-current="route.path.startsWith(item.section) ? 'page' : undefined" @click="open = false">{{ item.label }}</a>
<div class="wk-header-search"><Search /></div>

View File

@ -8,6 +8,8 @@
- `/docs/`:直接进入“快速上手”。
- `/docs/…`:完整文档,保留分类导航、搜索和侧栏。
站点只占用这两个路径:根目录下只有 `index.html`、`404.html` 和 `docs/`。官网的脚本、样式和图片都放在 `/docs/_home/` 下,所以上游网关只需转发 `/`(精确匹配)和 `/docs/` 前缀。`build` 会拒绝引用这两个路径以外资源的页面。
顶栏高 64px、横向铺满。两边使用 README 原版商标,共用颜色、字体和深浅色偏好;Logo 在当前标签返回官网。官网和文档各自使用适合当前页面的导航。
## 发布方式:静态文件 + Nginx
@ -36,7 +38,7 @@ sudo mkdir -p /srv/www/weknora/releases/20260915-1
sudo tar -xzf weknora-site-v0.8.2.tar.gz -C /srv/www/weknora/releases/20260915-1
```
解压后该目录下应直接有 `index.html`、`docs/`、`_next/`,无需再套一层 `static-site/`。
解压后该目录下应直接有 `index.html`、`404.html`、`docs/`,无需再套一层 `static-site/`。
### 3. 配置域名根目录

View File

@ -2,8 +2,10 @@
Logos identify supported integrations; their names and marks belong to their respective owners.
Paths below written as `public/brand/…`, `public/brands/…` and `public/product/…` live under `public/docs/_home/`, so the site serves them from `/docs/_home/` next to the rest of the documentation.
- WeKnora logo: `docs/images/logo.png` from the WeKnora repository (the README logo), copied unchanged to `public/brand/weknora-original.png`. The site preserves all lettering, graphics and proportions. CSS hides only the empty outer canvas and blends the white background into the page; dark mode uses an inverted presentation with hue rotation. The source image remains unchanged.
- WeKnora browser icon: copied unchanged from the existing product's `frontend/public/favicon.ico` into the homepage and documentation. The replacement square sail SVG is no longer shipped.
- WeKnora browser icon: copied unchanged from the existing product's `frontend/public/favicon.ico` into the documentation (`/docs/favicon.ico`), which the homepage also uses. The replacement square sail SVG is no longer shipped.
- Feishu, GitLab, Tencent IMA, Notion, Yuque, RSS, WeCom, Slack, Telegram: copied unchanged from the WeKnora frontend asset library.
- OpenAI, DeepSeek, Qwen, Hunyuan, Gemini, Ollama, MCP: static SVGs from [Lobe Icons](https://github.com/lobehub/lobe-icons), `@lobehub/icons-static-svg@1.95.0`. Upstream MIT license included with assets.
- Confluence, DingTalk: copied unchanged from the WeKnora frontend asset library (`frontend/src/assets/img/datasource-confluence.svg`, `frontend/src/assets/img/im/dingtalk.svg`).

View File

@ -7,5 +7,6 @@ The Next.js homepage is one part of the unified site. Run `npm run setup`, `npm
- `app/interactive.tsx`: responsive navigation, theme switch, and on-demand README video.
- `app/theme.ts`: VitePress-compatible theme persistence and pre-paint initialization.
- `../shared/brand.css`: shared light/dark design tokens.
- `public/docs/_home/`: homepage images. The site serves only `/` and `/docs/`, so build output and public assets both live under `/docs/_home/` (`homeAssets` in `../shared/header.ts`).
`npm run dev` can still preview the homepage alone during development. `/docs/` requires the combined preview from the parent directory.

View File

@ -1,6 +1,7 @@
import Image from "next/image";
import { homeAssets } from "../../shared/header";
/** Show the complete original artwork; the viewport only trims blank canvas. */
export function BrandLogo({ priority = false }: { priority?: boolean }) {
return <span className="wk-logo"><Image src="/brand/weknora-original.png" alt="WeKnora" width={945} height={650} priority={priority} /></span>;
return <span className="wk-logo"><Image src={`${homeAssets}/brand/weknora-original.png`} alt="WeKnora" width={945} height={650} priority={priority} /></span>;
}

View File

@ -1,5 +1,6 @@
import Image from "next/image";
import { Icon } from "./ui";
import { homeAssets } from "../../shared/header";
type Integration = { name: string; logo: string } | { name: string; icon: string };
@ -47,7 +48,7 @@ export const modelProviders: Integration[] = [
export function IntegrationMark({ item }: { item: Integration }) {
return <>
{"logo" in item
? <Image src={`/brands/${item.logo}`} alt="" aria-hidden="true" width={22} height={22} />
? <Image src={`${homeAssets}/brands/${item.logo}`} alt="" aria-hidden="true" width={22} height={22} />
: <Icon name={item.icon} />}
{item.name}
</>;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -1,10 +1,9 @@
"use client";
import Link from "next/link";
import { BrandLogo } from "./brand-logo";
import { useRef, useState, useSyncExternalStore } from "react";
import { Icon } from "./ui";
import { getThemeSnapshot, subscribeToTheme, toggleTheme } from "./theme";
import { siteNavigation, repositoryUrl, headerIcons } from "../../shared/header";
import { siteNavigation, repositoryUrl, headerIcons, homeAssets } from "../../shared/header";
import s from "./home.module.css";
const videoUrl = "https://github.com/user-attachments/assets/2819598d-3140-4623-814a-8162a22b653c";
@ -21,7 +20,7 @@ export function Header() {
const menu = useRef<HTMLButtonElement>(null);
return <header className="wk-header" onKeyDown={event => { if (event.key === "Escape" && open) { setOpen(false); menu.current?.focus(); } }}>
<div className="wk-header-inner">
<Link className="wk-brand" href="/" aria-label="WeKnora 首页"><BrandLogo priority /></Link>
<a className="wk-brand" href="/" aria-label="WeKnora 首页"><BrandLogo priority /></a>
<nav id="main-navigation" className={`wk-navigation ${open ? "is-open" : ""}`} aria-label="主导航" onClick={() => setOpen(false)}>
{siteNavigation.map(item => <a key={item.href} href={item.href}>{item.label}{item.badge && <span className="wk-new-label">{item.badge}</span>}</a>)}
<a className="wk-mobile-github" href={repositoryUrl} target="_blank" rel="noreferrer">GitHub <HeaderIcon name="external" /></a>
@ -48,7 +47,7 @@ export function ProductVideo() {
return <figure id="demo" className={s.videoFigure}>
<div className={s.videoTop}><span>产品演示 <span className={s.videoDot}>/</span> PRODUCT FILM</span><span>02:25 <span className={s.videoDot}>/</span> 1080P</span></div>
<div className={s.videoStage}>
<video ref={player} controls={started} playsInline preload="none" poster="/product/agent-chat.png" aria-label="WeKnora 产品介绍,英文旁白,中英字幕" aria-describedby="video-caption" tabIndex={started ? 0 : -1} onError={() => setFailed(true)} />
<video ref={player} controls={started} playsInline preload="none" poster={`${homeAssets}/product/agent-chat.png`} aria-label="WeKnora 产品介绍,英文旁白,中英字幕" aria-describedby="video-caption" tabIndex={started ? 0 : -1} onError={() => setFailed(true)} />
{!started && <button className={s.videoCover} onClick={play} aria-label="播放 WeKnora 产品介绍视频,2 分 25 秒"><span className={s.playCircle}><Icon name="play" /></span><span className={s.videoCoverTitle}>WeKnora 产品演示</span><span className={s.videoCoverHint}>播放产品介绍 · 2 分 25 秒</span></button>}
{failed && <div className={s.videoError} role="status"><p>视频暂时无法加载</p><a href={videoUrl} target="_blank" rel="noreferrer">在 GitHub 打开原视频 <Icon name="external" /></a></div>}
</div>

View File

@ -5,6 +5,8 @@ import { themeInitializationScript } from "./theme";
export const metadata: Metadata = {
title: "WeKnora — 帮你找到答案,并将知识付诸实践",
description: "腾讯开源知识框架 WeKnora,集 RAG 问答、Agent 推理与自动 Wiki 于一体。v0.8.2 让智能体操作本机浏览器、以 MCP Server 对外提供知识库,并支持对话分叉与回滚;支持私有化部署。",
// Reuse the documentation favicon so the homepage adds nothing at the site root.
icons: { icon: "/docs/favicon.ico" },
};
export default function RootLayout({

View File

@ -1,9 +1,9 @@
import { existsSync } from "node:fs";
import { join } from "node:path";
import Image from "next/image";
import Link from "next/link";
import { BrandLogo } from "./brand-logo";
import { Icon } from "./ui";
import { homeAssets } from "../../shared/header";
import { ProductGallery, type GalleryShot, type GallerySlide } from "./product-gallery";
import { Header, ProductVideo } from "./interactive";
import { clients, dataSources, modelProviders, IntegrationMark } from "./brands";
@ -23,7 +23,7 @@ const productShotExists = (src: string) => existsSync(join(process.cwd(), "publi
type SlideSource = Omit<GallerySlide, "shots"> & ({ image: string; alt: string } | { shots: Omit<GalleryShot, "available">[] });
const withAvailability = (slide: SlideSource): GallerySlide => {
const shots = "shots" in slide ? slide.shots : [{ image: slide.image, alt: slide.alt }];
return { name: slide.name, icon: slide.icon, title: slide.title, description: slide.description, link: slide.link, external: slide.external, shots: shots.map(shot => ({ ...shot, available: productShotExists(`/product/${shot.image}.png`) })) };
return { name: slide.name, icon: slide.icon, title: slide.title, description: slide.description, link: slide.link, external: slide.external, shots: shots.map(shot => ({ ...shot, available: productShotExists(`${homeAssets}/product/${shot.image}.png`) })) };
};
const releaseSlides = [
{ name: "本机浏览器", icon: "browser", shots: [
@ -107,13 +107,13 @@ export default function Home() {
<div className={s.sectionHeading}><div><p className={s.eyebrow}>GET STARTED</p><h2 id="closing-title">选择适合你的使用方式。</h2></div></div>
<div className={s.startGrid}>
<article className={s.startCard}>
<div className={s.startLabel}><Image className={s.startBrand} src="/brands/wechat-dialog.png" alt="微信对话开放平台 Logo" width={32} height={32} /><span>在线使用</span></div>
<div className={s.startLabel}><Image className={s.startBrand} src={`${homeAssets}/brands/wechat-dialog.png`} alt="微信对话开放平台 Logo" width={32} height={32} /><span>在线使用</span></div>
<h3>微信对话开放平台</h3>
<p>在线管理知识库,将问答服务接入公众号、小程序等微信场景。</p>
<a className={s.textLink} href="https://chatbot.weixin.qq.com/login" target="_blank" rel="noreferrer">进入平台 <Icon name="external" /></a>
</article>
<article className={s.startCard}>
<div className={s.startLabel}><Image className={s.startBrand} src="/brands/tencent-cloud.ico" alt="腾讯云 Logo" width={32} height={32} /><span>云端部署</span></div>
<div className={s.startLabel}><Image className={s.startBrand} src={`${homeAssets}/brands/tencent-cloud.ico`} alt="腾讯云 Logo" width={32} height={32} /><span>云端部署</span></div>
<h3>腾讯云轻量应用服务器</h3>
<p>通过应用模板部署 WeKnora,在自己的云服务器上运行。</p>
<a className={s.textLink} href="https://mc.tencent.com/s69nKCVz" target="_blank" rel="noreferrer">前往腾讯云部署 <Icon name="external" /></a>
@ -127,6 +127,6 @@ export default function Home() {
</div>
</section>
</main>
<footer className={`${s.shell} ${s.footer}`}><Link className={s.brand} href="/" aria-label="WeKnora 首页"><BrandLogo /></Link><p>Tencent Open Source · MIT License</p><nav aria-label="页脚导航"><a href={docs}>文档</a><a href={repo} target="_blank" rel="noreferrer">GitHub <Icon name="external" /></a><a href={`${repo}/blob/main/CHANGELOG.md`} target="_blank" rel="noreferrer">更新日志</a></nav></footer>
<footer className={`${s.shell} ${s.footer}`}><a className={s.brand} href="/" aria-label="WeKnora 首页"><BrandLogo /></a><p>Tencent Open Source · MIT License</p><nav aria-label="页脚导航"><a href={docs}>文档</a><a href={repo} target="_blank" rel="noreferrer">GitHub <Icon name="external" /></a><a href={`${repo}/blob/main/CHANGELOG.md`} target="_blank" rel="noreferrer">更新日志</a></nav></footer>
</div>;
}

View File

@ -3,6 +3,7 @@
import Image from "next/image";
import { useEffect, useRef, useState, type CSSProperties } from "react";
import { Icon } from "./ui";
import { homeAssets } from "../../shared/header";
import s from "./home.module.css";
export type GalleryShot = { label?: string; icon?: string; image: string; alt: string; available: boolean };
@ -91,7 +92,7 @@ export function ProductGallery({ id, label, slides }: { id: string; label: strin
</div>}
{(slide.link || slide.external) && <div className={s.slideLinks}>
{slide.link && <a className={s.textLink} href={slide.link}>了解更多 <Icon name="arrow" /></a>}
{slide.external && <a className={`${s.textLink} ${s.externalLink}`} href={slide.external.href} target="_blank" rel="noreferrer">{slide.external.logo && <Image src={`/brands/${slide.external.logo}`} alt="" aria-hidden="true" width={20} height={20} />}{slide.external.label}<Icon name="github" /></a>}
{slide.external && <a className={`${s.textLink} ${s.externalLink}`} href={slide.external.href} target="_blank" rel="noreferrer">{slide.external.logo && <Image src={`${homeAssets}/brands/${slide.external.logo}`} alt="" aria-hidden="true" width={20} height={20} />}{slide.external.label}<Icon name="github" /></a>}
</div>}
</div>
</div>)}
@ -101,7 +102,7 @@ export function ProductGallery({ id, label, slides }: { id: string; label: strin
<span><Icon name={activeShot.icon ?? active.icon} />{active.name}{active.shots.length > 1 && activeShot.label && <em className={s.viewLabel}>· {activeShot.label}</em>}</span>
<div className={s.cardActions}>
{activeShot.available
? <a className={s.textLink} href={`/product/${activeShot.image}.png`} target="_blank" rel="noreferrer" aria-label={`查看${active.name}原图(新窗口)`}>查看原图 <Icon name="external" /></a>
? <a className={s.textLink} href={`${homeAssets}/product/${activeShot.image}.png`} target="_blank" rel="noreferrer" aria-label={`查看${active.name}原图(新窗口)`}>查看原图 <Icon name="external" /></a>
: <span className={s.pendingLabel}>待补充</span>}
</div>
</div>
@ -111,8 +112,8 @@ export function ProductGallery({ id, label, slides }: { id: string; label: strin
const current = index === item && shotIndex === shot;
return <div key={entry.image} className={s.shotLayer} data-active={current} aria-hidden={!current}>
{entry.available
? <Image src={`/product/${entry.image}.png`} alt={entry.alt} width={3840} height={2112} sizes="(min-width: 1100px) 60vw, 100vw" />
: <div className={s.shotPlaceholder} role="img" aria-label={entry.alt}><span>截图待补充</span><code>{`website-docs/homepage/public/product/${entry.image}.png`}</code></div>}
? <Image src={`${homeAssets}/product/${entry.image}.png`} alt={entry.alt} width={3840} height={2112} sizes="(min-width: 1100px) 60vw, 100vw" />
: <div className={s.shotPlaceholder} role="img" aria-label={entry.alt}><span>截图待补充</span><code>{`website-docs/homepage/public${homeAssets}/product/${entry.image}.png`}</code></div>}
</div>;
}))}
</div>

View File

@ -5,6 +5,13 @@ import nextTs from "eslint-config-next/typescript";
const eslintConfig = defineConfig([
...nextVitals,
...nextTs,
{
rules: {
// <Link> navigation fetches RSC payloads from the site root, which the
// upstream router does not forward; plain links reload `/` instead.
"@next/next/no-html-link-for-pages": "off",
},
},
// Override default ignores of eslint-config-next.
globalIgnores([
// Default ignores of eslint-config-next:

View File

@ -1,9 +1,12 @@
import type { NextConfig } from "next";
import { resolve } from "node:path";
import { homeAssets } from "../shared/header";
const nextConfig: NextConfig = {
turbopack: { root: resolve(__dirname, "..") },
output: "export",
// Chunks are requested from /docs/_home/_next/; build-site.mjs moves out/_next there.
assetPrefix: homeAssets,
trailingSlash: true,
images: {
unoptimized: true,

View File

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 113 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 672 B

After

Width:  |  Height:  |  Size: 672 B

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 439 B

After

Width:  |  Height:  |  Size: 439 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 978 B

After

Width:  |  Height:  |  Size: 978 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 776 B

After

Width:  |  Height:  |  Size: 776 B

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 361 B

After

Width:  |  Height:  |  Size: 361 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 949 B

After

Width:  |  Height:  |  Size: 949 B

View File

Before

Width:  |  Height:  |  Size: 858 B

After

Width:  |  Height:  |  Size: 858 B

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 544 KiB

After

Width:  |  Height:  |  Size: 544 KiB

View File

Before

Width:  |  Height:  |  Size: 540 KiB

After

Width:  |  Height:  |  Size: 540 KiB

View File

Before

Width:  |  Height:  |  Size: 619 KiB

After

Width:  |  Height:  |  Size: 619 KiB

View File

Before

Width:  |  Height:  |  Size: 740 KiB

After

Width:  |  Height:  |  Size: 740 KiB

View File

Before

Width:  |  Height:  |  Size: 468 KiB

After

Width:  |  Height:  |  Size: 468 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

Before

Width:  |  Height:  |  Size: 644 KiB

After

Width:  |  Height:  |  Size: 644 KiB

View File

Before

Width:  |  Height:  |  Size: 351 KiB

After

Width:  |  Height:  |  Size: 351 KiB

View File

Before

Width:  |  Height:  |  Size: 888 KiB

After

Width:  |  Height:  |  Size: 888 KiB

View File

Before

Width:  |  Height:  |  Size: 539 KiB

After

Width:  |  Height:  |  Size: 539 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

Before

Width:  |  Height:  |  Size: 670 KiB

After

Width:  |  Height:  |  Size: 670 KiB

View File

@ -17,7 +17,7 @@ assert.match(html, /https:\/\/github.com\/user-attachments\/assets\/2819598d-314
assert.ok(!/<video[^>]+autoplay/i.test(html), 'Do not autoplay the product film');
const wiki = html.match(/<section id="wiki"[\s\S]*?<\/section>/)?.[0];
assert.ok(wiki, 'The homepage must include a dedicated Wiki section');
for (const term of ['/product/wiki-browser.png', '/product/wiki-graph.png', '/product/wiki-revision-history.png', 'id="wiki-gallery"', '/docs/03-features/14-wiki.html', '来源引用', '知识图谱', '版本差异']) {
for (const term of ['/docs/_home/product/wiki-browser.png', '/docs/_home/product/wiki-graph.png', '/docs/_home/product/wiki-revision-history.png', 'id="wiki-gallery"', '/docs/03-features/14-wiki.html', '来源引用', '知识图谱', '版本差异']) {
assert.ok(wiki.includes(term), `Missing Wiki showcase content: ${term}`);
}
const ids = new Set([...html.matchAll(/\bid="([^"]+)"/g)].map(match => match[1]));
@ -31,9 +31,9 @@ for (const asset of assets) {
if (file.isDirectory()) file = await stat(join(path, 'index.html'));
assert.ok(file.isFile() && file.size > 0, `Missing local asset: ${asset}`);
}
const pendingShots = [...html.matchAll(/website-docs\/homepage\/public(\/product\/[\w.-]+)/g)].map(match => match[1]);
const pendingShots = [...html.matchAll(/website-docs\/homepage\/public(\/docs\/_home\/product\/[\w.-]+)/g)].map(match => match[1]);
// Gallery slides without a file render their placeholder only once selected; read the flag from the page data.
for (const [, image] of html.matchAll(/\\?"image\\?":\\?"([\w-]+)\\?"[^{}]*?\\?"available\\?":false/g)) pendingShots.push(`/product/${image}.png`);
for (const [, image] of html.matchAll(/\\?"image\\?":\\?"([\w-]+)\\?"[^{}]*?\\?"available\\?":false/g)) pendingShots.push(`/docs/_home/product/${image}.png`);
if (pendingShots.length) console.warn(`Product screenshots still pending (placeholder shown): ${[...new Set(pendingShots)].join(', ')}`);
assert.match(html, /aria-controls="main-navigation"/);
assert.match(html, /aria-label="播放 WeKnora 产品介绍视频/);

View File

@ -1,5 +1,5 @@
import { spawnSync } from 'node:child_process';
import { cpSync, rmSync, existsSync } from 'node:fs';
import { cpSync, rmSync, existsSync, readdirSync, renameSync } from 'node:fs';
import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
@ -14,7 +14,15 @@ run('homepage', 'build');
run('.', 'check:docs');
run('.', 'build:docs');
const output = resolve(root, 'homepage/out');
rmSync(resolve(output, 'docs'), { recursive: true, force: true });
// The upstream router forwards only `/` and `/docs/`, so the export keeps just the
// two HTML entry points at the root. Chunks join the public assets under
// /docs/_home/ (next.config.ts assetPrefix); RSC payloads and the not-found
// route are never requested because the homepage uses plain links.
const homeAssets = resolve(output, 'docs/_home');
renameSync(resolve(output, '_next'), resolve(homeAssets, '_next'));
for (const entry of readdirSync(output)) {
if (!['index.html', '404.html', 'docs'].includes(entry)) rmSync(resolve(output, entry), { recursive: true, force: true });
}
cpSync(resolve(root, '.vitepress/dist'), resolve(output, 'docs'), { recursive: true });
run('homepage', 'audit:content');
const check = spawnSync(process.execPath, ['scripts/check-site.mjs', output], { cwd: root, stdio: 'inherit' });

View File

@ -18,6 +18,9 @@ for (const retired of ['/demo/', '/demo/1/', '/redesign/', '/redesign/1/', '/dem
assert.equal(await resolveSiteFile(root, retired), null, `Retired demo must not be published: ${retired}`);
}
const failures = [];
for (const entry of await readdir(root)) {
if (!['index.html', '404.html', 'docs'].includes(entry)) failures.push(`/${entry}: only index.html, 404.html and docs/ may sit at the site root`);
}
// Screenshot.vue renders a labelled placeholder until the image is added, so a
// missing docs screenshot is reported as pending instead of failing the build.
const pendingShots = new Set();
@ -32,6 +35,8 @@ for (const file of pages) {
for (const [, raw] of tag.matchAll(/(?:href|src|poster)="([^"]+)"/g)) {
const url = new URL(raw.replaceAll('&amp;', '&'), base);
if (url.origin !== base.origin) continue;
// The upstream router forwards only these two prefixes to this service.
if (url.pathname !== base.pathname && url.pathname !== '/' && !url.pathname.startsWith('/docs/')) failures.push(`${route}: ${url.pathname} is outside / and /docs/`);
if (!checked.has(url.pathname)) checked.set(url.pathname, !!await resolveSiteFile(root, url.pathname));
if (!checked.get(url.pathname)) {
if (/class="wk-shot-img"/.test(tag) && url.pathname.startsWith('/docs/screenshots/')) pendingShots.add(url.pathname);

View File

@ -67,7 +67,7 @@ try {
assert.equal(redirect.status, 308);
assert.equal(new URL(redirect.headers.get('location'), origin).origin, origin);
assert.equal(new URL(redirect.headers.get('location'), origin).pathname, '/docs/');
const assets = new Set(['/brand/weknora-original.png', '/product/wiki-browser.png', '/docs/favicon.ico']);
const assets = new Set(['/docs/_home/brand/weknora-original.png', '/docs/_home/product/wiki-browser.png', '/docs/favicon.ico']);
for (const path of ['/', '/docs/', '/docs/03-features/14-wiki', '/docs/03-features/14-wiki.html']) {
const response = await fetch(origin + path);
assert.equal(response.status, 200, path);
@ -82,7 +82,7 @@ try {
if (url.origin === origin) assets.add(url.pathname);
}
}
assert.ok([...assets].some(path => path.startsWith('/_next/')), 'Homepage scripts are missing');
assert.ok([...assets].some(path => path.startsWith('/docs/_home/_next/')), 'Homepage scripts are missing');
assert.ok([...assets].some(path => path.startsWith('/docs/assets/')), 'Documentation scripts are missing');
for (const asset of assets) {
const response = await fetch(origin + asset);

View File

@ -178,7 +178,7 @@ try {
const image = document.querySelector('.wk-brand img');
return image?.complete && image.naturalWidth === 945 && image.naturalHeight === 650;
});
assert.equal(await page.locator('.wk-brand img').getAttribute('src'), '/brand/weknora-original.png');
assert.equal(await page.locator('.wk-brand img').getAttribute('src'), '/docs/_home/brand/weknora-original.png');
await checkVisibleControl(page, '.wk-theme-toggle');
}
}

View File

@ -6,6 +6,10 @@ export const siteNavigation = [
{ label: '企业部署', href: '/#enterprise', badge: '' },
{ label: '文档', href: '/docs/', badge: '' },
];
// The site sits behind an upstream router that forwards only `/` and `/docs/`.
// Everything else the homepage loads (Next chunks, images) is served from here:
// Next's assetPrefix points at it and homepage/public mirrors the same path.
export const homeAssets = '/docs/_home';
export const repositoryUrl = 'https://github.com/Tencent/WeKnora';
export const headerIcons: Record<string, string> = {
sun: 'M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0M12 2v2m0 16v2M2 12h2m16 0h2M5 5l1.5 1.5m11 11L19 19M5 19l1.5-1.5m11-11L19 5',