fix: 修复教程简介中链接点击跳转 URL 缺少 base URL 问题
This commit is contained in:
@@ -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: '简体中文',
|
||||
|
@@ -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
5
docs/env.mts
Normal file
@@ -0,0 +1,5 @@
|
||||
// 全局配置
|
||||
|
||||
// 部署后网站的 base URL。
|
||||
// 注意:前后都带 /
|
||||
export const base = '/tutorials/'
|
Reference in New Issue
Block a user