File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<script >
22 import { page } from ' $app/state' ;
33 import * as Breadcrumb from ' $lib/components/ui/breadcrumb/index.js' ;
4- import { resolve } from ' $app/paths' ;
5-
6- let base = resolve (' ' ).replaceAll (' /' , ' ' );
7- if (base === ' ' ) base = ' /' ;
4+ const githubUrl = ' vhtmui.github.io' ;
85
96 let pathName_items = $derived .by (() => {
10- let pn_array = [ ' / ' ]. concat ( page .url .pathname .split (' /' ).filter (Boolean ) );
7+ let pn_array = page .url .pathname .split (' /' ).filter (Boolean );
118
12- if (base in pn_array) {
13- pn_array = [base].concat (pn_array .splice (0 , pn_array .indexOf (base) + 1 ));
9+ let hasGithubUrl = false ;
10+ if (pn_array .includes (githubUrl)) {
11+ pn_array = pn_array .splice (pn_array .indexOf (githubUrl));
12+ hasGithubUrl = true ;
1413 }
1514
16- return pn_array .map ((pathname , index ) => {
17- let name = pathname === ' /' ? ' Home' : pathname;
18- let href = pn_array
19- .map ((v ) => (v === ' /' ? ' ' : v))
20- .slice (0 , index + 1 )
21- .join (' /' );
22- if (href === ' ' ) href = ' /' ;
23- // 该href无需格式化或拼接
15+ const pn = pn_array .map ((pathname , index ) => {
16+ let name = pathname;
17+ let href = ' /' + pn_array .slice (0 , index + 1 ).join (' /' );
2418 return { name, href };
2519 });
20+
21+ if (hasGithubUrl) {
22+ pn[0 ] = { name: ' Home' , href: ' /' + githubUrl };
23+ } else {
24+ pn .unshift ({ name: ' Home' , href: ' /' });
25+ }
26+
27+ return pn;
2628 });
2729 </script >
2830
Original file line number Diff line number Diff line change 11import adapter from '@sveltejs/adapter-static' ;
22
3- // const base = process.argv.includes('dev') ? '' : '/vhtmui.github.io';
4- export const base = '/vhtmui.github.io' ;
3+ const base = process . argv . includes ( 'dev' ) ? '' : '/vhtmui.github.io' ;
54
65/** @type {import('@sveltejs/kit').Config } */
76const config = {
You can’t perform that action at this time.
0 commit comments