File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
packages/docs/src/components Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 33 import { htmlToJsx , prefixClassNames } from " $lib/actions.svelte.js"
44 import { t } from " $lib/i18n.svelte.js"
55 import Clipboard from " $components/Clipboard.svelte"
6+ import { prefix } from " $lib/stores"
7+
68 let {
79 title = undefined ,
810 desc = undefined ,
1820 let wrapper = $state ()
1921 let htmlSlot = $state ()
2022 let jsxSlot = $state ()
23+ let htmlContent = $state (" " )
24+ let jsxContent = $state (" " )
2125
2226 let titleStr = $derived (
2327 title
3337 document .getElementById (location .hash .slice (1 )).click ()
3438 }
3539 })
40+
41+ // Subscribe to prefix changes
42+ $effect (() => {
43+ const unsubscribe = prefix .subscribe ((value ) => {
44+ if (htmlSlot) {
45+ htmlContent = htmlSlot .firstChild .innerHTML
46+ }
47+ if (jsxSlot) {
48+ jsxContent = jsxSlot .firstChild .innerHTML
49+ }
50+ })
51+
52+ return () => unsubscribe ()
53+ })
3654 </script >
3755
3856<div
104122 {@render html ()}
105123 </div >
106124 {#if onMount }
107- <Clipboard strip ={true } text ={htmlSlot ?. firstChild . innerHTML } />
125+ <Clipboard strip ={true } text ={htmlContent } />
108126 {/if }
109127 </div >
110128 </div >
136154 </div >
137155 </div >
138156 {#if onMount }
139- <Clipboard strip ={true } text ={jsxSlot ?. firstChild . innerHTML } />
157+ <Clipboard strip ={true } text ={jsxContent } />
140158 {/if }
141159 </div >
142160 </div >
You can’t perform that action at this time.
0 commit comments