Move COMPONENT_API to src/generated
This commit is contained in:
parent
425c8cd1d3
commit
cbc85ca98f
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ node_modules
|
|||||||
.env.*
|
.env.*
|
||||||
!.env.example
|
!.env.example
|
||||||
.vercel
|
.vercel
|
||||||
|
generated/
|
||||||
@ -20,7 +20,7 @@ export default function sveld() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// This generates a `COMPONENT_API.json` with sveld in the `/_app` folder on build, which is used by the docs about components (only when built statically)
|
// This generates a `COMPONENT_API.json` with sveld in the `/_app` folder on build, which is used by the docs about components (only when built statically)
|
||||||
async generateBundle(options, bundle) {
|
async buildStart() {
|
||||||
const output = {};
|
const output = {};
|
||||||
|
|
||||||
const componentFiles = await fs.readdir(path.resolve('./src/lib/components'))
|
const componentFiles = await fs.readdir(path.resolve('./src/lib/components'))
|
||||||
@ -31,11 +31,13 @@ export default function sveld() {
|
|||||||
output[fileName] = await parseRaw(raw, filePath)
|
output[fileName] = await parseRaw(raw, filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emitFile({
|
try {
|
||||||
type: 'asset',
|
await fs.mkdir(path.resolve('./src/generated'))
|
||||||
fileName: 'COMPONENT_API.json',
|
} catch {
|
||||||
source: JSON.stringify(output),
|
// Do nothing, directory already exists
|
||||||
})
|
}
|
||||||
|
|
||||||
|
await fs.writeFile(path.resolve('./src/generated/COMPONENT_API.json'), JSON.stringify(output))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
// TODO: Make square icon `md` more rounded
|
||||||
|
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import { classCombine } from '$lib/utils/classCombine'
|
import { classCombine } from '$lib/utils/classCombine'
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
// TODO: sizes
|
// TODO: sizes
|
||||||
// TODO: icon only buttons should have uniform padding
|
// TODO: icon only buttons should have uniform padding
|
||||||
|
// TODO: Could be a class
|
||||||
|
|
||||||
import { classCombine } from '$lib/utils/classCombine'
|
import { classCombine } from '$lib/utils/classCombine'
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
// TODO: Add fade out styling on top and bottom
|
||||||
|
|
||||||
import Checkbox from './Checkbox.svelte'
|
import Checkbox from './Checkbox.svelte'
|
||||||
import type { SvelteComponent } from 'svelte'
|
import type { SvelteComponent } from 'svelte'
|
||||||
import VirtualList from 'svelte-tiny-virtual-list'
|
import VirtualList from 'svelte-tiny-virtual-list'
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import IconPencil from 'virtual:icons/heroicons-outline/pencil'
|
import IconPencil from 'virtual:icons/heroicons-outline/pencil'
|
||||||
import { page } from '$app/stores'
|
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 = ''
|
export let title = ''
|
||||||
if (!title) title = fileName
|
if (!title) title = fileName
|
||||||
@ -14,7 +15,7 @@
|
|||||||
if (import.meta.env.DEV) {
|
if (import.meta.env.DEV) {
|
||||||
import(`../../../lib/components/${title}.svelte?raw&sveld`).then(output => api = output.default)
|
import(`../../../lib/components/${title}.svelte?raw&sveld`).then(output => api = output.default)
|
||||||
} else {
|
} else {
|
||||||
fetch('/_app/COMPONENT_API.json').then(res => res.json()).then(output => api = output[`${title}.svelte`])
|
api = COMPONENT_API[`${title}.svelte`]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user