|
10 | 10 |
|
11 | 11 | <script>
|
12 | 12 | import { onMount } from 'svelte';
|
13 |
| - import { locate } from 'locate-character'; |
14 | 13 | import { process_example } from '../../components/Repl/process_example.js';
|
15 | 14 | import AppControls from './_components/AppControls/index.svelte';
|
16 | 15 | import Repl from '../../components/Repl/index.svelte';
|
17 | 16 |
|
18 |
| - export let version, example, gist_id; |
19 |
| -
|
20 |
| - console.log({ example }); |
| 17 | + export let version; |
| 18 | + export let example; |
| 19 | + export let gist_id; |
21 | 20 |
|
22 | 21 | let repl;
|
23 | 22 | let gist;
|
|
52 | 51 | relaxed = false;
|
53 | 52 | fetch(`gist/${gist_id}`).then(r => r.json()).then(data => {
|
54 | 53 | gist = data;
|
55 |
| - const { id, description, files } = data; |
| 54 | + const { description, files } = data; |
56 | 55 |
|
57 | 56 | name = description;
|
58 | 57 |
|
|
84 | 83 |
|
85 | 84 | repl.set({ components });
|
86 | 85 | });
|
87 |
| - } |
88 |
| - }); |
| 86 | + } else { |
| 87 | + relaxed = true; |
| 88 | + fetch(`examples/${example}.json`).then(async response => { |
| 89 | + if (response.ok) { |
| 90 | + const data = await response.json(); |
89 | 91 |
|
90 |
| - function load_example(slug) { |
91 |
| - console.log(`loading ${slug}`); |
| 92 | + name = data.title; |
92 | 93 |
|
93 |
| - relaxed = true; |
94 |
| - fetch(`examples/${slug}.json`).then(async response => { |
95 |
| - if (response.ok) { |
96 |
| - const data = await response.json(); |
97 |
| -
|
98 |
| - name = data.title; |
99 |
| -
|
100 |
| - const components = process_example(data.files); |
101 |
| - repl.set({ components }); |
| 94 | + const components = process_example(data.files); |
| 95 | + repl.set({ components }); |
102 | 96 |
|
103 |
| - gist = null; |
104 |
| - } |
105 |
| - }); |
106 |
| - } |
| 97 | + gist = null; |
| 98 | + } |
| 99 | + }); |
| 100 | + } |
| 101 | + }); |
107 | 102 |
|
108 | 103 | function handle_fork(event) {
|
109 | 104 | example = null;
|
110 | 105 | gist = event.detail.gist;
|
111 | 106 | gist_id = gist.id;
|
112 | 107 | }
|
113 |
| -
|
114 |
| - $: if (process.browser && example) { |
115 |
| - load_example(example); |
116 |
| - } |
117 | 108 | </script>
|
118 | 109 |
|
119 | 110 | <style>
|
|
0 commit comments