Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I import icons dynamically in Svelte? #351

Closed
JPaulMora opened this issue Mar 4, 2024 · 1 comment
Closed

I import icons dynamically in Svelte? #351

JPaulMora opened this issue Mar 4, 2024 · 1 comment

Comments

@JPaulMora
Copy link

I have a sidebar menu in a svelte +layout.svelte with dynamic links:

<script lang="ts">
        import { menuNavLinks } from '$lib/links';
	import ArrowTD from 'virtual:icons/heroicons/arrow-trending-down-16-solid';
</script>

my links.ts looks like this:

// Navigation Sitemap

export type List = Array<{ href: string; label: string; keywords: string; badge?: string }>;
export const menuNavLinks: Record<string, Array<{ title: string; list: List }>> = {
	'/docs': [
		{
			title: 'Docs',
			list: [
				{ href: '/docs/introduction', label: 'Introduction', keywords: 'svelte, sirens, license, release' },
				{ href: '/docs/get-started', label: 'Get Started', keywords: 'start, install, cli, tailwind, themes, stylesheets' },
				{ href: '/docs/quickstart', label: 'Quickstart', keywords: 'start, setup, tutorial, guide' }
			]
		},
//etc..

I want to define the icon name as part of this structure and have it auto imported, if that makes sense. Thanks in advance.

@JPaulMora
Copy link
Author

Closing this issue, found a partial solution on #5 (comment). Based on that thread, dynamic icons are not possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant