-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add 'Open in StackBlitz' links to example code fences
- Loading branch information
Showing
11 changed files
with
67 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,53 @@ | ||
<script lang="ts"> | ||
import { page } from '$app/stores' | ||
import Icon from '@iconify/svelte' | ||
import { onMount } from 'svelte' | ||
import { name } from '../../package.json' | ||
import CopyButton from './CopyButton.svelte' | ||
export let src: string // just here to avoid unknown prop warning | ||
export let meta: Record<string, string> | ||
let node: HTMLElement | ||
export let src: string // just here to avoid unknown prop warning | ||
src | ||
$: ({ id } = meta) | ||
let node: HTMLElement | ||
onMount(() => { | ||
// replace $lib with 'name' in code | ||
node.innerHTML = node.innerHTML.replace(/\$lib/g, name) | ||
// replace $lib with package name in code | ||
node.innerHTML = node.innerHTML.replaceAll(`$lib`, name) | ||
}) | ||
$: stackblitz_url = `https://stackblitz.com/github/janosh/svelte-multiselect?file=${encodeURIComponent( | ||
`src/routes${$page.route.id}/+page.svx` | ||
)}` | ||
</script> | ||
|
||
{#if id} | ||
<div {id}> | ||
<slot name="example" /> | ||
</div> | ||
{:else} | ||
<div id={meta.id}> | ||
<slot name="example" /> | ||
{/if} | ||
|
||
<pre><aside> | ||
<CopyButton content={node?.innerText} /> | ||
</aside><code bind:this={node}><slot name="code" /></code></pre> | ||
<div> | ||
<aside> | ||
<CopyButton content={node?.innerText} /> | ||
<a href={stackblitz_url} class="btn" target="_blank" rel="noreferrer"> | ||
<Icon icon="simple-icons:stackblitz" inline /> | ||
Open in StackBlitz | ||
</a> | ||
</aside> | ||
<pre><code bind:this={node}><slot name="code" /></code></pre> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
div { | ||
position: relative; | ||
} | ||
pre { | ||
margin-top: 2em; | ||
background-color: rgba(255, 255, 255, 0.05); | ||
position: relative; | ||
} | ||
aside { | ||
position: absolute; | ||
top: 1em; | ||
right: 1em; | ||
display: flex; | ||
gap: 1em; | ||
gap: 1ex; | ||
place-items: center; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters