Skip to content

Commit 434f588

Browse files
committed
add stackblitz
1 parent 2ebad5c commit 434f588

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"eslint-plugin-svelte3": "4.0.0",
4848
"husky": "8.0.1",
4949
"mdsvex": "0.10.6",
50+
"package": "link:package",
5051
"postcss": "8.4.16",
5152
"postcss-load-config": "4.0.1",
5253
"prettier": "2.7.1",

pnpm-lock.yaml

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<script lang="ts">
2+
import GeneralObserver from "./general-observer.svelte"
3+
4+
export let width: string = '100'
5+
export let height: string = '500'
6+
export let id: string = ''
7+
export let view: 'editor' | 'preview' | 'default' = 'default'
8+
export let clickToLoad: boolean = true //ctl
9+
export let hideNavigation: boolean = false //hideNavigation
10+
export let hideExplorer: boolean = true
11+
export let theme: string | 'light' | 'dark' | 'default' = 'dark'
12+
export let file: string | undefined
13+
14+
let baseUrl = "https://stackblitz.com/edit/vitejs-vite-yyoood?embed=1"
15+
const config = {
16+
ctl: `${clickToLoad ? 1 : 0}`,
17+
hideExplorer: `${hideExplorer ? 1 : 0}`,
18+
hideNavigation: `${hideNavigation ? 1: 0}`,
19+
theme
20+
}
21+
if(view !== 'default') {
22+
config['view'] = view
23+
}
24+
if(file) {
25+
config['file'] = file
26+
}
27+
const queryString = new URLSearchParams(config)
28+
const src = `${baseUrl}&${queryString.toString()}`
29+
</script>
30+
31+
<GeneralObserver {height} {width}>
32+
<iframe
33+
{height}
34+
class="stackblitz-sveltekit-embed"
35+
title={`stackblitz-${id}`}
36+
{src}
37+
frameborder="no"
38+
allowfullscreen
39+
style={`
40+
width: 100%;
41+
`}
42+
/>
43+
</GeneralObserver>

src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export { default as GenericEmbed } from './components/generic-embed.svelte'
77
export { default as SimpleCast } from './components/simple-cast.svelte'
88
export { default as SoundCloud } from './components/sound-cloud.svelte'
99
export { default as Spotify } from './components/spotify.svelte'
10+
export { default as StackBlitz } from './components/stackblitz.svelte'
1011
export { default as Tweet } from './components/tweet.svelte'
1112
export { default as Vimeo } from './components/vimeo.svelte'
1213
export { default as YouTube } from './components/you-tube.svelte'

src/routes/+page.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Tweet,
1212
Vimeo,
1313
YouTube,
14+
StackBlitz
1415
} from 'sveltekit-embed'
1516
import { Head } from 'svead'
1617
import { page } from '$app/stores'
@@ -322,3 +323,10 @@ Usage:
322323
Output:
323324

324325
<YouTube youTubeId="L7_z8rcbFPg" />
326+
327+
328+
## StackBlitz
329+
330+
Output:
331+
332+
<StackBlitz id="vitejs-vite-yyoood" />

0 commit comments

Comments
 (0)