Move COMPONENT_API to src/generated

This commit is contained in:
venashial
2022-03-30 14:05:15 -07:00
parent 425c8cd1d3
commit cbc85ca98f
6 changed files with 17 additions and 8 deletions

View File

@@ -1,8 +1,9 @@
<script lang="ts">
import IconPencil from 'virtual:icons/heroicons-outline/pencil'
import { page } from '$app/stores'
import COMPONENT_API from '../../../generated/COMPONENT_API.json'
export let fileName = $page.url.pathname.substring($page.url.pathname.lastIndexOf('/') + 1)
export let fileName = $page.url.pathname.substring($page.url.pathname.lastIndexOf('/') + 1).replace('.html', '')
export let title = ''
if (!title) title = fileName
@@ -14,7 +15,7 @@
if (import.meta.env.DEV) {
import(`../../../lib/components/${title}.svelte?raw&sveld`).then(output => api = output.default)
} else {
fetch('/_app/COMPONENT_API.json').then(res => res.json()).then(output => api = output[`${title}.svelte`])
api = COMPONENT_API[`${title}.svelte`]
}
}
</script>