|
25 | 25 | url: 'https://layerchart.com/docs', |
26 | 26 | description: 'A charting/visualization library for Svelte 5' |
27 | 27 | }; |
28 | | - const pageName = page.url.href.split('/').pop(); |
29 | | - const llmBaseContext = `The following is a documentation page from ${pkg.name} (${pkg.description}). The page URL for "${pageName}" is ${page.url.href}. Be ready to help answer questions about this page.`; |
| 28 | + // Use origin + pathname to exclude hash/anchor from URLs |
| 29 | + const pageUrl = $derived(`${page.url.origin}${page.url.pathname}`); |
| 30 | + const pageName = $derived(page.url.pathname.split('/').pop()); |
| 31 | + const llmBaseContext = $derived( |
| 32 | + `The following is a documentation page from ${pkg.name} (${pkg.description}). The page URL for "${pageName}" is ${pageUrl}. Be ready to help answer questions about this page.` |
| 33 | + ); |
30 | 34 |
|
31 | 35 | const llms = $derived([ |
32 | 36 | // Add source button if component page |
|
46 | 50 | label: 'View Page Markdown', |
47 | 51 | icon: SimpleIconsMarkdown, |
48 | 52 | fn: async () => { |
49 | | - markdownContent = await fetch(`${page.url.href}/llms.txt`).then((res) => res.text()); |
| 53 | + markdownContent = await fetch(`${pageUrl}/llms.txt`).then((res) => res.text()); |
50 | 54 | openMarkdownModal = true; |
51 | 55 | } |
52 | 56 | }, |
|
85 | 89 | size="sm" |
86 | 90 | color="primary" |
87 | 91 | onclick={async () => { |
88 | | - const md = await fetch(`${page.url.href}/llms.txt`).then((res) => res.text()); |
| 92 | + const md = await fetch(`${pageUrl}/llms.txt`).then((res) => res.text()); |
89 | 93 | copy(md); |
90 | 94 | }} |
91 | 95 | > |
|
170 | 174 | <div class="grid grid-cols-[1fr_auto] gap-3 items-center p-4"> |
171 | 175 | <div class="overflow-auto"> |
172 | 176 | <div class="text-lg font-semibold">Page Markdown</div> |
173 | | - <div class="text-xs text-surface-content/50 truncate">{page.url.href}/llms.txt</div> |
| 177 | + <div class="text-xs text-surface-content/50 truncate">{pageUrl}/llms.txt</div> |
174 | 178 | </div> |
175 | 179 |
|
176 | 180 | <Button |
177 | 181 | icon={SimpleIconsMarkdown} |
178 | 182 | variant="fill-light" |
179 | 183 | color="primary" |
180 | | - href="{page.url.href}/llms.txt" |
| 184 | + href="{pageUrl}/llms.txt" |
181 | 185 | target="_blank" |
182 | 186 | > |
183 | 187 | Open Raw |
|
0 commit comments