mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
docs: use sapper/cypress for e2e testing
This commit is contained in:
parent
0bb5e1952f
commit
ccdf6af78d
36 changed files with 4373 additions and 26 deletions
38
docs/src/routes/components/[slug].svelte
Normal file
38
docs/src/routes/components/[slug].svelte
Normal file
|
@ -0,0 +1,38 @@
|
|||
<script context="module">
|
||||
export async function preload({ params }) {
|
||||
const res = await this.fetch(`components/${params.slug}.json`);
|
||||
const data = await res.json();
|
||||
|
||||
if (res.status === 200) {
|
||||
return { data };
|
||||
} else {
|
||||
this.error(res.status, data.message);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
export let data = {};
|
||||
|
||||
import { onMount } from "svelte";
|
||||
|
||||
let component = undefined;
|
||||
|
||||
onMount(async () => {
|
||||
try {
|
||||
component = await import(`../examples/${data.title}.svelte`);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{data.title}</title>
|
||||
</svelte:head>
|
||||
|
||||
<h1>{data.title}</h1>
|
||||
|
||||
{#if component}
|
||||
<svelte:component this={component.default} />
|
||||
{/if}
|
Loading…
Add table
Add a link
Reference in a new issue