1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

fix: 修复教程简介中链接点击跳转 URL 缺少 base URL 问题

This commit is contained in:
2025-03-14 00:21:38 +08:00
parent d9e436b04e
commit 82684043bc
3 changed files with 10 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import { defineConfig } from 'vitepress'
import { base } from '../env.mts'
import { sidebar } from '../sidebar.mts'
import { nav } from '../nav.mts'
import {
@@ -50,7 +51,7 @@ export default defineConfig({
title: "就这么弄 (🚧 施工中)",
description: "简单步骤与实用技巧",
base: '/tutorials/',
base: base,
locales: {
root: {
label: '简体中文',

View File

@@ -29,6 +29,7 @@
<script setup lang="ts">
import { useRouter, DefaultTheme } from 'vitepress';
import { base } from '../env.mts';
const props = defineProps<{
base?: string,
@@ -38,7 +39,8 @@ const props = defineProps<{
const router = useRouter()
function goTo(link: string) {
const target = (props.base || '') + link?.replace('.md', '.html')
const baseUrl = (base.endsWith('/') ? base.substring(0, base.length - 1) : base)
const target = baseUrl + (props.base || '') + link?.replace('.md', '.html')
console.log('base', props.base)
console.log('link', link)
console.log('target', target)

5
docs/env.mts Normal file
View File

@@ -0,0 +1,5 @@
// 全局配置
// 部署后网站的 base URL。
// 注意:前后都带 /
export const base = '/tutorials/'