2026-03-05 14:03:27 +01:00
|
|
|
import { highLightCode } from './createCodeExamples';
|
2023-06-04 16:59:38 +02:00
|
|
|
|
|
|
|
|
type CodeExampleType = {
|
2024-02-01 22:38:21 +09:00
|
|
|
title: string;
|
|
|
|
|
language: string;
|
|
|
|
|
code: string;
|
|
|
|
|
}[];
|
2023-06-04 16:59:38 +02:00
|
|
|
|
|
|
|
|
const getIconCodes = (): CodeExampleType => {
|
|
|
|
|
return [
|
|
|
|
|
{
|
2025-12-10 02:18:57 -08:00
|
|
|
language: 'html',
|
2024-06-25 09:56:55 +02:00
|
|
|
title: 'Vanilla',
|
|
|
|
|
code: `\
|
2025-12-10 02:18:57 -08:00
|
|
|
<script>
|
|
|
|
|
import { createIcons } from 'lucide';
|
2024-06-28 10:25:27 +02:00
|
|
|
import { $CamelCase } from '@lucide/lab';
|
2024-06-25 09:56:55 +02:00
|
|
|
|
|
|
|
|
createIcons({
|
|
|
|
|
icons: {
|
2024-06-28 10:25:27 +02:00
|
|
|
$CamelCase
|
2024-06-25 09:56:55 +02:00
|
|
|
}
|
|
|
|
|
});
|
2025-12-10 02:18:57 -08:00
|
|
|
</script>
|
2024-06-25 09:56:55 +02:00
|
|
|
|
2025-12-10 02:18:57 -08:00
|
|
|
<i data-lucide="$Name"></i>\
|
2024-06-25 09:56:55 +02:00
|
|
|
`,
|
2023-06-04 16:59:38 +02:00
|
|
|
},
|
|
|
|
|
{
|
2023-11-28 21:02:23 +01:00
|
|
|
language: 'tsx',
|
2023-06-04 16:59:38 +02:00
|
|
|
title: 'React',
|
2024-06-25 09:56:55 +02:00
|
|
|
code: `import { Icon } from 'lucide-react';
|
2024-06-28 10:25:27 +02:00
|
|
|
import { $CamelCase } from '@lucide/lab';
|
2023-06-04 16:59:38 +02:00
|
|
|
|
|
|
|
|
const App = () => {
|
|
|
|
|
return (
|
2024-06-28 10:25:27 +02:00
|
|
|
<Icon iconNode={$CamelCase} />
|
2023-06-04 16:59:38 +02:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default App;
|
|
|
|
|
`,
|
|
|
|
|
},
|
|
|
|
|
{
|
2023-11-28 21:02:23 +01:00
|
|
|
language: 'vue',
|
|
|
|
|
title: 'Vue',
|
|
|
|
|
code: `<script setup>
|
2024-06-25 09:56:55 +02:00
|
|
|
import { Icon } from 'lucide-vue-next';
|
2024-06-28 10:25:27 +02:00
|
|
|
import { $CamelCase } from '@lucide/lab';
|
2023-06-04 16:59:38 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-01-06 14:12:20 +01:00
|
|
|
<Icon :iconNode="$CamelCase" />
|
2023-06-04 16:59:38 +02:00
|
|
|
</template>
|
|
|
|
|
`,
|
|
|
|
|
},
|
|
|
|
|
{
|
2023-11-28 21:02:23 +01:00
|
|
|
language: 'svelte',
|
2023-06-04 16:59:38 +02:00
|
|
|
title: 'Svelte',
|
2023-11-28 21:02:23 +01:00
|
|
|
code: `<script>
|
2024-06-25 09:56:55 +02:00
|
|
|
import { Icon } from 'lucide-svelte';
|
2024-06-28 10:25:27 +02:00
|
|
|
import { $CamelCase } from '@lucide/lab';
|
2023-06-04 16:59:38 +02:00
|
|
|
</script>
|
|
|
|
|
|
2025-01-06 14:12:20 +01:00
|
|
|
<Icon iconNode={$CamelCase} />
|
2023-06-04 16:59:38 +02:00
|
|
|
`,
|
|
|
|
|
},
|
|
|
|
|
{
|
2023-11-28 21:02:23 +01:00
|
|
|
language: 'tsx',
|
2023-06-04 16:59:38 +02:00
|
|
|
title: 'Preact',
|
2024-06-25 09:56:55 +02:00
|
|
|
code: `import { Icon } from 'lucide-preact';
|
2024-06-28 10:25:27 +02:00
|
|
|
import { $CamelCase } from '@lucide/lab';
|
2023-06-04 16:59:38 +02:00
|
|
|
|
|
|
|
|
const App = () => {
|
|
|
|
|
return (
|
2024-06-28 10:25:27 +02:00
|
|
|
<Icon iconNode={$CamelCase} />
|
2023-06-04 16:59:38 +02:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default App;
|
|
|
|
|
`,
|
|
|
|
|
},
|
|
|
|
|
{
|
2023-11-28 21:02:23 +01:00
|
|
|
language: 'tsx',
|
2023-06-04 16:59:38 +02:00
|
|
|
title: 'Solid',
|
2024-06-25 09:56:55 +02:00
|
|
|
code: `import { Icon } from 'lucide-solid';
|
2024-06-28 10:25:27 +02:00
|
|
|
import { $CamelCase } from '@lucide/lab';
|
2023-06-04 16:59:38 +02:00
|
|
|
|
|
|
|
|
const App = () => {
|
|
|
|
|
return (
|
2024-06-28 10:25:27 +02:00
|
|
|
<Icon iconNode={$CamelCase} />
|
2023-06-04 16:59:38 +02:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default App;
|
|
|
|
|
`,
|
|
|
|
|
},
|
|
|
|
|
{
|
2023-11-28 21:02:23 +01:00
|
|
|
language: 'tsx',
|
2023-06-04 16:59:38 +02:00
|
|
|
title: 'Angular',
|
2023-11-28 21:02:23 +01:00
|
|
|
code: `// app.module.ts
|
2024-06-28 10:25:27 +02:00
|
|
|
import { LucideAngularModule } from 'lucide-angular';
|
|
|
|
|
import { $CamelCase } from '@lucide/lab';
|
2023-06-04 16:59:38 +02:00
|
|
|
|
|
|
|
|
@NgModule({
|
|
|
|
|
imports: [
|
2026-03-06 13:42:49 +05:30
|
|
|
LucideAngularModule.pick({ $PascalCase: $CamelCase })
|
2023-06-04 16:59:38 +02:00
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// app.component.html
|
2026-03-06 13:42:49 +05:30
|
|
|
<lucide-icon name="$PascalCase"></lucide-icon>
|
2023-06-04 16:59:38 +02:00
|
|
|
`,
|
2024-02-01 22:38:21 +09:00
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
};
|
2023-06-04 16:59:38 +02:00
|
|
|
|
|
|
|
|
export default async function createCodeExamples() {
|
|
|
|
|
const codes = getIconCodes();
|
|
|
|
|
|
2023-11-28 21:02:23 +01:00
|
|
|
const codeExamplePromises = codes.map(async ({ title, language, code }, index) => {
|
2023-06-04 16:59:38 +02:00
|
|
|
const isFirst = index === 0;
|
|
|
|
|
|
2023-11-28 21:02:23 +01:00
|
|
|
const codeString = await highLightCode(code, language, isFirst);
|
2023-06-04 16:59:38 +02:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
title,
|
2023-11-28 21:02:23 +01:00
|
|
|
language: language,
|
|
|
|
|
code: codeString,
|
2023-06-04 16:59:38 +02:00
|
|
|
};
|
2024-02-01 22:38:21 +09:00
|
|
|
});
|
2023-06-04 16:59:38 +02:00
|
|
|
|
|
|
|
|
return Promise.all(codeExamplePromises);
|
|
|
|
|
}
|