const getIconCodes = (name: string): CodeExampleType => {
@@ -24,7 +23,6 @@ const getIconCodes = (name: string): CodeExampleType => {
`,
},
],
- breakpoint: 'base',
},
react: {
title: 'React',
@@ -48,7 +46,6 @@ export default App;
metastring: '{1,4}',
},
],
- breakpoint: 'base',
},
vue: {
title: 'Vue 3',
@@ -66,7 +63,6 @@ import { ${pascalCase} } from 'lucide-vue-next';
metastring: '{2,6}',
},
],
- breakpoint: 'base',
},
svelte: {
title: 'Svelte',
@@ -86,7 +82,6 @@ import { ${pascalCase} } from 'lucide-svelte';
metastring: '{2,5}',
},
],
- breakpoint: 'sm',
},
preact:{
title: 'Preact',
@@ -110,7 +105,6 @@ export default App;
metastring: '{1,4}',
},
],
- breakpoint: 'md',
},
solid:{
title: 'Solid',
@@ -134,7 +128,6 @@ export default App;
metastring: '{1,4}',
},
],
- breakpoint: 'md',
},
angular: {
title: 'Angular',
@@ -152,10 +145,8 @@ import { LucideAngularModule, ${pascalCase} } from 'lucide-angular';\r
// app.component.html
`,
- metastring: '{2,6}',
},
],
- breakpoint: 'base',
},
font: {
title: 'Icon Font',
@@ -170,7 +161,6 @@ import { LucideAngularModule, ${pascalCase} } from 'lucide-angular';\r
`,
},
],
- breakpoint: 'md',
},
flutter: {
title: 'Flutter',
@@ -179,10 +169,8 @@ import { LucideAngularModule, ${pascalCase} } from 'lucide-angular';\r
language: 'javascript',
code: `Icon(LucideIcons.${name});
`,
- metastring: '{1}',
},
],
- breakpoint: 'sm',
},
};
}
diff --git a/docs/.vitepress/lib/createCodeExamples.ts b/docs/.vitepress/lib/createCodeExamples.ts
new file mode 100644
index 000000000..05690a229
--- /dev/null
+++ b/docs/.vitepress/lib/createCodeExamples.ts
@@ -0,0 +1,236 @@
+import { startCase, camelCase } from "lodash";
+import {
+ BUNDLED_LANGUAGES,
+ type IThemeRegistration
+} from 'shiki'
+import {
+ getHighlighter,
+} from 'shiki-processor'
+
+type CodeExampleType = {
+ title: string,
+ lang: string,
+ codes: {
+ language?: string,
+ code: string,
+ metastring?: string,
+ }[],
+}[]
+
+const getIconCodes = (name: string): CodeExampleType => {
+ const pascalCase = startCase(camelCase(name)).replace(/\s/g, '')
+
+ return [
+ {
+ lang: 'html',
+ title: 'HTML',
+ codes: [
+ {
+ language: 'html',
+ code: `
+`,
+ },
+ ],
+ },
+ {
+ lang: 'tsx',
+ title: 'React',
+ codes: [
+ {
+ language: 'tsx',
+ code: `import { ${pascalCase} } from 'lucide-react';
+
+const App = () => {
+ return (
+ <${pascalCase}
+ color="red"
+ size={48}
+ strokeWidth={1.5}
+ />
+ );
+};
+
+export default App;
+`,
+ metastring: '{1,4}',
+ },
+ ],
+ },
+ {
+ lang: 'vue',
+ title: 'Vue 3',
+ codes: [
+ {
+ language: 'vue',
+ code: `
+ <${pascalCase} color="red" :size="32" />
+
+
+
+`,
+ metastring: '{2,6}',
+ },
+ ],
+ },
+ {
+ lang: 'svelte',
+ title: 'Svelte',
+ codes: [
+ {
+ language: 'vue',
+ code: `
+
+<${pascalCase}
+ color={red}
+ size={48}
+ strokeWidth={1.5}
+/>
+`,
+ metastring: '{2,5}',
+ },
+ ],
+ },
+ {
+ lang: 'preact',
+ title: 'Preact',
+ codes: [
+ {
+ language: 'tsx',
+ code: `import { ${pascalCase} } from 'lucide-preact';
+
+const App = () => {
+ return (
+ <${pascalCase}
+ color="red"
+ size={48}
+ strokeWidth={1.5}
+ />
+ );
+};
+
+export default App;
+`,
+ metastring: '{1,4}',
+ },
+ ],
+ },
+ {
+ lang: 'solid',
+ title: 'Solid',
+ codes: [
+ {
+ language: 'tsx',
+ code: `import { ${pascalCase} } from 'lucide-solid';
+
+const App = () => {
+ return (
+ <${pascalCase}
+ color="red"
+ size={48}
+ strokeWidth={1.5}
+ />
+ );
+};
+
+export default App;
+`,
+ metastring: '{1,4}',
+ },
+ ],
+ },
+ {
+ lang: 'angular',
+ title: 'Angular',
+ codes: [
+ {
+ language: 'tsx',
+ code: `// app.module.ts
+import { LucideAngularModule, ${pascalCase} } from 'lucide-angular';\r
+@NgModule({
+ imports: [
+ LucideAngularModule.pick({ ${pascalCase} })
+ ],
+})
+
+// app.component.html
+
+`,
+ },
+ ],
+ },
+ {
+ lang: 'html',
+ title: 'Icon Font',
+ codes: [
+ {
+ language: 'html',
+ code: `
+
+
+`,
+ },
+ ],
+ },
+ {
+ lang: 'dart',
+ title: 'Flutter',
+ codes: [
+ {
+ language: 'dart',
+ code: `Icon(LucideIcons.${name});
+`,
+ },
+ ],
+ },
+ ]
+}
+
+export type ThemeOptions =
+ | IThemeRegistration
+ | { light: IThemeRegistration; dark: IThemeRegistration }
+
+const highLightCode = async (code: string, lang: string, active?: boolean) => {
+ const highlighter = await getHighlighter({
+ themes: ['material-theme-palenight'],
+ langs: [...BUNDLED_LANGUAGES],
+ processors: []
+ })
+
+ const highlightedCode = highlighter.codeToHtml(code, {
+ lang,
+ // lineOptions,
+ theme: 'material-theme-palenight'
+ }).replace('background-color: #292D3E', '')
+
+ return `
+
+ ${lang}
+ ${highlightedCode}
+
`
+}
+
+
+export default async function createCodeExamples(name: string) {
+ const codes = getIconCodes(name);
+
+ const codeExamplePromises = codes.map(async (codeTemplate, index) => {
+ const { title, lang, codes } = codeTemplate;
+ const isFirst = index === 0;
+
+ const code = await highLightCode(codes[0].code, codes[0].language || lang, isFirst);
+
+ return {
+ title,
+ language: codes[0].language || lang,
+ code,
+ };
+ })
+
+ return Promise.all(codeExamplePromises);
+}
diff --git a/docs/icons/[name].md b/docs/icons/[name].md
index b43fecd24..21d057d84 100644
--- a/docs/icons/[name].md
+++ b/docs/icons/[name].md
@@ -8,13 +8,22 @@ prev: false
sidebar: true
---
-::: code-group
-
-```html-vue [HTML]
-{{codeExample.html.codes[0].code}}
-```
-
-```jsx-vue [React]
-{{codeExample.react.codes[0].code}}
-```
-
-```vue-vue [Vue]
-{{codeExample.vue.codes[0].code}}
-```
-
-```svelte-vue [Svelte]
-{{codeExample.svelte.codes[0].code}}
-```
-
-```jsx-vue [Preact]
-{{codeExample.preact.codes[0].code}}
-```
-
-```jsx-vue [Solid]
-{{codeExample.solid.codes[0].code}}
-```
-
-```tsx-vue [Angular]
-{{codeExample.angular.codes[0].code}}
-```
-
-```html-vue [Font]
-{{codeExample.font.codes[0].code}}
-```
-
-```html-vue [Flutter]
-{{codeExample.flutter.codes[0].code}}
-```
-:::
+
+
+