fix(frontend): link docs to the public docs site instead of GitHub
In-app doc links opened raw Markdown on GitHub. Point them at the deployed site (https://weknora.weixin.qq.com/docs/) instead, collected in utils/docsUrl.ts with a test that checks every linked page and anchor still exists in website-docs. The issue template's FAQ link moves too.main
parent
e22a8367ef
commit
9253b2c1dc
|
|
@ -1,7 +1,7 @@
|
|||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: WeKnora Documentation
|
||||
url: https://github.com/Tencent/WeKnora/blob/main/website-docs/01-getting-started/05-troubleshooting.md
|
||||
url: https://weknora.weixin.qq.com/docs/01-getting-started/05-troubleshooting
|
||||
about: Check WeKnora FAQ
|
||||
- name: Discussions
|
||||
url: https://github.com/Tencent/WeKnora/discussions
|
||||
|
|
|
|||
|
|
@ -646,6 +646,7 @@ import CredentialResource, {
|
|||
} from '@/components/credentials/CredentialResource.vue'
|
||||
import { shouldShowOllamaUnavailableTip } from '@/components/modelEditorSourceState'
|
||||
import { WEKNORA_CLOUD_PROVIDER, WKC_MODEL_KINDS, WKC_MODEL_NAME_BY_KIND } from '@/utils/weknoraCloudModels'
|
||||
import { docsUrl } from '@/utils/docsUrl'
|
||||
|
||||
interface CustomHeaderItem {
|
||||
key: string
|
||||
|
|
@ -703,8 +704,7 @@ const PROTOCOL_OPTIONS = [
|
|||
] as const
|
||||
|
||||
/** Field reference for parameters.spec.compat, per protocol and model type. */
|
||||
const COMPAT_DOC_URL =
|
||||
'https://github.com/Tencent/WeKnora/blob/main/website-docs/03-features/06-models.md#协议兼容覆盖-compat-json'
|
||||
const COMPAT_DOC_URL = docsUrl('modelsCompat')
|
||||
|
||||
/** Legacy thinking_control values still honoured by catalog.Resolve. */
|
||||
const LEGACY_THINKING_CONTROL_VALUES = ['none', 'enable_thinking', 'thinking_type', 'chat_template_kwargs'] as const
|
||||
|
|
|
|||
|
|
@ -765,6 +765,7 @@ import { useI18n } from 'vue-i18n'
|
|||
import SettingDrawer from '@/components/settings/SettingDrawer.vue'
|
||||
import SandboxBackendBadge from '@/components/settings/SandboxBackendBadge.vue'
|
||||
import { useDeploymentCapabilitiesStore } from '@/stores/deploymentCapabilities'
|
||||
import { docsUrl } from '@/utils/docsUrl'
|
||||
import {
|
||||
checkSandboxConfig,
|
||||
createSandboxConfig,
|
||||
|
|
@ -816,7 +817,7 @@ const isMaskedSecret = (value?: string) => value === secretPlaceholder
|
|||
// the sandbox account cannot write.
|
||||
const defaultDockerImage = 'wechatopenai/weknora-sandbox:main'
|
||||
|
||||
const clusterGuideUrl = 'https://github.com/Tencent/WeKnora/blob/main/website-docs/06-development/04-sandbox-deployment.md'
|
||||
const clusterGuideUrl = docsUrl('sandboxDeployment')
|
||||
const e2bApiKeysUrl = 'https://e2b.dev/dashboard?tab=keys'
|
||||
|
||||
const backendOptions = computed(() => {
|
||||
|
|
|
|||
|
|
@ -215,6 +215,7 @@ import { useRoleLabel, useHomeTenant } from '@/composables/useRoleLabel'
|
|||
import { getRootZoom, rectToCssPx, cssViewportSize } from '@/utils/zoom'
|
||||
import { openNewUserGuide } from '@/config/contextualGuides'
|
||||
import { SETTINGS_MANAGEMENT_SHORTCUT_MIN_ROLE } from '@/config/settingsAccess'
|
||||
import { docsUrl } from '@/utils/docsUrl'
|
||||
const { t } = useI18n()
|
||||
|
||||
const router = useRouter()
|
||||
|
|
@ -493,7 +494,7 @@ const reopenGuide = () => {
|
|||
|
||||
const openDocs = () => {
|
||||
menuVisible.value = false
|
||||
window.open('https://github.com/Tencent/WeKnora/tree/main/website-docs', '_blank')
|
||||
window.open(docsUrl('home'), '_blank')
|
||||
}
|
||||
|
||||
// 打开 GitHub
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ async function fixture(options: {
|
|||
if (name === '@/stores/modelProviders') return { useModelProvidersStore: () => providersStore }
|
||||
if (name === '@/api/model') return { getWeKnoraCloudStatus: async () => ({ has_models: true, needs_reinit: false }) }
|
||||
if (name === '@/utils/weknoraCloudModels') return require('../utils/weknoraCloudModels.ts')
|
||||
if (name === '@/utils/docsUrl') return require('../utils/docsUrl.ts')
|
||||
if (name === '@/stores/modelProvidersState') return require('../stores/modelProvidersState.ts')
|
||||
if (name === '@/utils/reasoningEffort') return require('../utils/reasoningEffort.ts')
|
||||
if (name === '@/utils/contextWindow') return require('../utils/contextWindow.ts')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
import { strict as assert } from 'node:assert'
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import { test } from 'node:test'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { DOC_PAGES, docsUrl } from './docsUrl'
|
||||
|
||||
const WEBSITE_DOCS = resolve(dirname(fileURLToPath(import.meta.url)), '../../../website-docs')
|
||||
|
||||
// VitePress default slugify for the headings we link to: explicit `{#id}`
|
||||
// wins, otherwise lowercase with whitespace and punctuation collapsed to `-`.
|
||||
function headingIds(markdown: string): Set<string> {
|
||||
const ids = new Set<string>()
|
||||
for (const line of markdown.split('\n')) {
|
||||
const m = /^#{1,6}\s+(.*?)\s*$/.exec(line)
|
||||
if (!m) continue
|
||||
const explicit = /\{#([^}]+)\}$/.exec(m[1])
|
||||
if (explicit) {
|
||||
ids.add(explicit[1])
|
||||
continue
|
||||
}
|
||||
ids.add(
|
||||
m[1]
|
||||
.toLowerCase()
|
||||
.replace(/[\s~`!@#$%^&*()+=[\]{}|\\;:'",.<>/?]+/g, '-')
|
||||
.replace(/^-+|-+$/g, ''),
|
||||
)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
test('every linked doc page and anchor exists in website-docs', () => {
|
||||
for (const [key, target] of Object.entries(DOC_PAGES)) {
|
||||
const [page, anchor] = target.split('#')
|
||||
const file = resolve(WEBSITE_DOCS, page ? `${page}.md` : 'index.md')
|
||||
assert.ok(existsSync(file), `${key}: ${file} not found`)
|
||||
if (anchor) {
|
||||
assert.ok(headingIds(readFileSync(file, 'utf8')).has(anchor), `${key}: #${anchor} not found in ${file}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('docsUrl points at the public docs site', () => {
|
||||
assert.equal(docsUrl('home'), 'https://weknora.weixin.qq.com/docs/')
|
||||
assert.equal(docsUrl('models'), 'https://weknora.weixin.qq.com/docs/03-features/06-models')
|
||||
})
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/** Public deployment of website-docs (VitePress, base `/docs/`). */
|
||||
export const DOCS_BASE_URL = 'https://weknora.weixin.qq.com/docs/'
|
||||
|
||||
/**
|
||||
* Doc pages linked from the UI, as website-docs paths without the `.md`
|
||||
* suffix. docsUrl.test.ts checks each one (and its anchor) still exists.
|
||||
*/
|
||||
export const DOC_PAGES = {
|
||||
home: '',
|
||||
tenantAuth: '03-features/01-tenant-auth',
|
||||
models: '03-features/06-models',
|
||||
modelsCompat: '03-features/06-models#协议兼容覆盖-compat-json',
|
||||
knowledgeGraph: '03-features/09-knowledge-graph',
|
||||
imIntegration: '03-features/12-im-integration',
|
||||
apiOverview: '04-api/01-api-overview',
|
||||
troubleshootingMigrations: '01-getting-started/05-troubleshooting#database-migrations',
|
||||
sandboxDeployment: '06-development/04-sandbox-deployment',
|
||||
} as const
|
||||
|
||||
export type DocPage = keyof typeof DOC_PAGES
|
||||
|
||||
export function docsUrl(page: DocPage): string {
|
||||
return DOCS_BASE_URL + DOC_PAGES[page]
|
||||
}
|
||||
|
|
@ -702,6 +702,7 @@ import {
|
|||
} from '@/config/apiKeyCapabilities'
|
||||
import { normalizeAPIKeyKnowledgeBaseIDs } from './apiKeyScope'
|
||||
import { consumeApiPlaygroundSSE } from './apiPlaygroundSSE'
|
||||
import { docsUrl } from '@/utils/docsUrl'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
|
|
@ -1431,7 +1432,7 @@ const saveDesktopPort = async () => {
|
|||
}
|
||||
|
||||
function openApiDoc() {
|
||||
window.open('https://github.com/Tencent/WeKnora/blob/main/website-docs/04-api/01-api-overview.md', '_blank')
|
||||
window.open(docsUrl('apiOverview'), '_blank')
|
||||
}
|
||||
|
||||
function openCreateAPIKeyDialog() {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<p class="section-description">
|
||||
{{ $t('agentEditor.im.description') }}
|
||||
<a
|
||||
href="https://github.com/Tencent/WeKnora/blob/main/website-docs/03-features/12-im-integration.md"
|
||||
:href="docsUrl('imIntegration')"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="doc-link"
|
||||
|
|
@ -62,6 +62,7 @@ import ChromeExtensionLanding from '@/views/integrations/ChromeExtensionLanding.
|
|||
import ClawSkillLanding from '@/views/integrations/ClawSkillLanding.vue'
|
||||
import CliIntegrationLanding from '@/views/integrations/CliIntegrationLanding.vue'
|
||||
import type { IntegrationTab } from '@/config/integrations'
|
||||
import { docsUrl } from '@/utils/docsUrl'
|
||||
|
||||
const filterAgentId = ref('')
|
||||
|
||||
|
|
|
|||
|
|
@ -326,6 +326,7 @@ import { useI18n } from 'vue-i18n'
|
|||
import { extractTextRelations, fabriText, fabriTag, type Node, type Relation } from '@/api/initialization'
|
||||
import { useEditorResourcesStore } from '@/stores/editorResources'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { docsUrl } from '@/utils/docsUrl'
|
||||
|
||||
const { t } = useI18n()
|
||||
const authStore = useAuthStore()
|
||||
|
|
@ -587,8 +588,7 @@ const loadSystemInfo = async (force = false) => {
|
|||
}
|
||||
|
||||
const graphGuideUrl =
|
||||
import.meta.env.VITE_KG_GUIDE_URL ||
|
||||
'https://github.com/Tencent/WeKnora/blob/main/website-docs/03-features/09-knowledge-graph.md'
|
||||
import.meta.env.VITE_KG_GUIDE_URL || docsUrl('knowledgeGraph')
|
||||
|
||||
// Open guide documentation to show how to enable graph database
|
||||
const handleOpenGraphGuide = () => {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
? 'modelSettings.builtinModels.descriptionAdmin'
|
||||
: 'modelSettings.builtinModels.description') }}
|
||||
</p>
|
||||
<a class="doc-link" href="https://github.com/Tencent/WeKnora/blob/main/website-docs/03-features/06-models.md" target="_blank"
|
||||
<a class="doc-link" :href="docsUrl('models')" target="_blank"
|
||||
rel="noopener noreferrer">
|
||||
{{ $t('modelSettings.builtinModels.viewGuide') }}
|
||||
<t-icon name="link" class="link-icon" />
|
||||
|
|
@ -311,6 +311,7 @@ import { useUIStore } from '@/stores/ui'
|
|||
import { focusKbEditorSection } from '@/config/contextualGuides'
|
||||
import { useChatResourcesStore } from '@/stores/chatResources'
|
||||
import { useModelProvidersStore } from '@/stores/modelProviders'
|
||||
import { docsUrl } from '@/utils/docsUrl'
|
||||
import {
|
||||
formatContextWindow,
|
||||
isDefaultContextWindow,
|
||||
|
|
|
|||
|
|
@ -218,6 +218,7 @@ import SettingDrawer from '@/components/settings/SettingDrawer.vue'
|
|||
import { useConfirmDelete } from '@/components/settings/useConfirmDelete'
|
||||
import { getSession } from '@/api/chat/index'
|
||||
import { useDeploymentCapabilitiesStore } from '@/stores/deploymentCapabilities'
|
||||
import { docsUrl } from '@/utils/docsUrl'
|
||||
import {
|
||||
deleteSandboxConfig,
|
||||
getSandboxConfigInventory,
|
||||
|
|
@ -238,7 +239,7 @@ const dockerBackendEnabled = computed(() =>
|
|||
deploymentCapabilities.isSupported('settings.sandbox.docker'),
|
||||
)
|
||||
|
||||
const sandboxGuideUrl = 'https://github.com/Tencent/WeKnora/blob/main/website-docs/06-development/04-sandbox-deployment.md'
|
||||
const sandboxGuideUrl = docsUrl('sandboxDeployment')
|
||||
|
||||
const backendTypes = [...NAMED_SANDBOX_BACKEND_TYPES]
|
||||
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@
|
|||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { getSystemInfo, type SystemInfo } from '@/api/system'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { docsUrl } from '@/utils/docsUrl'
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
|
|
@ -245,8 +246,7 @@ function formatUptime(totalSeconds: number): string {
|
|||
return parts.join(' ')
|
||||
}
|
||||
|
||||
const troubleshootingDocsURL =
|
||||
'https://github.com/Tencent/WeKnora/blob/main/website-docs/01-getting-started/05-troubleshooting.md#database-migrations'
|
||||
const troubleshootingDocsURL = docsUrl('troubleshootingMigrations')
|
||||
|
||||
// Pre-fills a new issue with the current migration error so users don't have to
|
||||
// paste it manually. Body is intentionally minimal — the bug template will fill
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
{{ $t('tenantMember.sectionDescription') }}
|
||||
<a
|
||||
class="doc-link"
|
||||
href="https://github.com/Tencent/WeKnora/blob/main/website-docs/03-features/01-tenant-auth.md"
|
||||
:href="docsUrl('tenantAuth')"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
|
|
@ -535,6 +535,7 @@ import {
|
|||
revokeInvitation,
|
||||
type TenantInvitation,
|
||||
} from '@/api/tenant/invitations'
|
||||
import { docsUrl } from '@/utils/docsUrl'
|
||||
import {
|
||||
listAuditLog,
|
||||
type AuditLog,
|
||||
|
|
|
|||
Loading…
Reference in New Issue