File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ export const csr = false;
66
77export const load = ( { request } ) => {
88 let hash ;
9+ let url = new URL ( request . url ) ;
910 try {
1011 hash = process . env . COMMIT_HASH || process . env . CF_PAGES_COMMIT_SHA || undefined ;
1112 } catch ( e ) {
@@ -16,6 +17,23 @@ export const load = ({ request }) => {
1617 date : new Date ( ) . toUTCString ( ) ,
1718 year : new Date ( ) . getFullYear ( ) ,
1819 ip : getIP ( request ) ,
19- host : request . headers . get ( 'host' )
20+ host : request . headers . get ( 'host' ) ,
21+ breadcrumbs : getBreadcrumbs ( url )
2022 } ;
2123} ;
24+
25+ const getBreadcrumbs = ( url : URL ) : { name : string ; url : string } [ ] => {
26+ return url . pathname
27+ . split ( '/' )
28+ . slice ( 1 )
29+ . filter ( ( fragment ) => fragment !== '' )
30+ . map ( ( fragment , index ) => {
31+ return {
32+ name : fragment ,
33+ url : url . pathname
34+ . split ( '/' )
35+ . slice ( 0 , index + 2 )
36+ . join ( '/' )
37+ } ;
38+ } ) ;
39+ } ;
Original file line number Diff line number Diff line change 66 export let host = data .host ;
77 export let ip = data .ip ;
88 export let year = data .year ;
9+ export let breadcrumbs = data .breadcrumbs ;
910 </script >
1011
1112<svelte:head >
1718{date }
1819{#if host && ip }Serving {host } to {ip }{/if }
1920{#if hash }On commit <a href ={` https://github.com/rosvik/248.no/commit/${hash } ` }>{hash }</a >{/if }
20-
21+ {#if breadcrumbs .length > 0 }
22+ <a href ="/" >248.no</a > {#each breadcrumbs as b }> <a href ={b .url }>{b .name }</a > {/each }
23+ {/if }
2124
2225</pre >
2326<slot />
You can’t perform that action at this time.
0 commit comments