Skip to content

Commit 30d2c6e

Browse files
authored
feat: resolve image 404 and playground jump link issues (#88)
1 parent 8c60939 commit 30d2c6e

3 files changed

Lines changed: 18 additions & 12 deletions

File tree

.vitepress/theme/components/CustomHeader.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<img
1010
:src="
1111
isDark
12-
? '/images/logo-opentiny-next-text-dark.svg'
13-
: '/images/logo-opentiny-next-text.svg'
12+
? `${prefix}images/logo-opentiny-next-text-dark.svg`
13+
: `${prefix}images/logo-opentiny-next-text.svg`
1414
"
1515
alt="OpenTiny NEXT"
1616
class="logo-icon"
@@ -119,8 +119,8 @@
119119
<img
120120
:src="
121121
isDark
122-
? '/images/logo-opentiny-next-text-dark.svg'
123-
: '/images/logo-opentiny-next-text.svg'
122+
? `${prefix}logo-opentiny-next-text-dark.svg`
123+
: `${prefix}logo-opentiny-next-text.svg`
124124
"
125125
alt="OpenTiny NEXT"
126126
class="logo-icon"

.vitepress/theme/home/index.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,15 @@
6767
</div>
6868
</template>
6969
<script setup>
70+
import { useData } from "vitepress";
71+
const { site } = useData();
72+
const prefix = site.value.base || "/";
73+
7074
const nextDates = [
7175
{
7276
nextDateLeft: [
7377
{
74-
icon: '/images/logo-active-next-sdk.svg',
78+
icon: `${prefix}images/logo-active-next-sdk.svg`,
7579
title: 'NEXT-SDKs',
7680
desc: 'OpenTiny NEXT-SDKs 是一套前端智能应用开发工具包,旨在简化 WebAgent 的集成与使用,支持多种编程语言和前端框架,帮助开发者快速实现智能化功能。'
7781
},
@@ -92,8 +96,8 @@ const nextDates = [
9296
title: '快速开始',
9397
desc: '使用 OpenTiny NEXT-SDKs,只需要以下四步,就可以把你的前端应用变成智能应用。',
9498
links: [
95-
{ text: '让你的应用智能化',icon: '/images/icon-app.svg', url: '/next-sdk/guide/#让你的应用智能化' },
96-
{ text: '浏览器直接引入',icon: '/images/icon-browser.svg', url: '/next-sdk/guide/#浏览器直接引入' },
99+
{ text: '让你的应用智能化',icon: `${prefix}images/icon-app.svg`, url: '/next-sdk/guide/#让你的应用智能化' },
100+
{ text: '浏览器直接引入',icon: `${prefix}images/icon-browser.svg`, url: '/next-sdk/guide/#浏览器直接引入' },
97101
]
98102
},
99103
{
@@ -111,7 +115,7 @@ const nextDates = [
111115
nextDateLeft: [
112116
{
113117
title: 'TinyRobot',
114-
icon: '/images/logo-active-tiny-robot.svg',
118+
icon: `${prefix}images/logo-active-tiny-robot.svg`,
115119
desc: 'TinyRobot是符合OpenTiny Design 设计体系的 AI 组件库,提供了丰富的AI交互组件,助力开发者快速构建AI应用。'
116120
},
117121
{
@@ -140,8 +144,8 @@ const nextDates = [
140144
title: '指南',
141145
desc: 'TinyRobot是符合OpenTiny Design 设计体系的 AI 组件库,提供了丰富的AI交互组件,助力开发者快速构建AI应用。',
142146
links: [
143-
{ text: '安装',icon: '/images/icon-tool.svg', url: '/tiny-robot/guide/quick-start.html#安装' },
144-
{ text: '引入与使用',icon: '/images/icon-download.svg', url: '/tiny-robot/guide/quick-start.html#引入与使用' },
147+
{ text: '安装',icon: `${prefix}images/icon-tool.svg`, url: '/tiny-robot/guide/quick-start.html#安装' },
148+
{ text: '引入与使用',icon: `${prefix}images/icon-download.svg`, url: '/tiny-robot/guide/quick-start.html#引入与使用' },
145149
]
146150
},
147151
{

.vitepress/theme/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ function listenCodePlaygroundEvent() {
8686
if (typeof window === 'undefined' || window.__CODE_PLAYGROUND_LISTENED__) {
8787
return
8888
}
89+
const route = useRoute();
8990

9091
window.__CODE_PLAYGROUND_LISTENED__ = true
9192
document.addEventListener('code-playground', (event) => {
@@ -136,7 +137,8 @@ function listenCodePlaygroundEvent() {
136137
files,
137138
extraImports,
138139
})
139-
140-
window.open(`https://playground.opentiny.design/tiny-robot.html` + store.serialize(), '_blank')
140+
if(route.path.includes('tiny-robot')){
141+
window.open(`https://playground.opentiny.design/tiny-robot.html` + store.serialize(), '_blank')
142+
}
141143
})
142144
}

0 commit comments

Comments
 (0)