Files
lucide/docs/.vitepress/lib/codeExamples/createLabCodeExamples.ts
T
Eric FennisandClaude Opus 5.5 7981a0798a chore(docs|site): Vitepress 2 upgrade (#5164)
* chore(docs): upgrade to VitePress 2

- Bump vitepress to 2.0.0-alpha.21
- Drop direct @docsearch/js and @docsearch/css deps; VitePress 2 ships
  DocSearch v4 and imports its styles itself
- VPNavBarSearch override: use the new VPAlgoliaSearchBox props
  (algoliaOptions + openRequest) instead of dispatching synthetic
  keydown events
- VPCarbonAds override: replace removed useAside composable with a
  media query, matching upstream
- VPFooter override: use useLayout from vitepress/theme instead of the
  removed useSidebar().hasSidebar

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G9u8FhZukDbCKe1ZFByn43

* Fix types and imports

* Fix ts imports

* fix styling

* Update mediaqueries

* chore(docs): remove unused theme overrides

VitePress 2 has no VPIconAlignLeft.vue for the alias to replace (the
local nav uses the vpi-text-align-start icon class), and the Hero and
HeroMatrix overrides aren't imported anywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(docs): use rem media queries in MCP and waitlist styles

Matches the rest of the theme and VitePress 2, which switched its
breakpoints to rem.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(docs): don't fail the build when GitHub's release API drops

The home hero's data loader let a network error from the GitHub
releases API escape, which failed the whole docs build in CI
("fetch failed: other side closed"). Retry once, then fall back to
null and hide the version badge instead of rendering "vundefined".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Add sentry

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-24 18:00:43 +01:00

135 lines
2.4 KiB
TypeScript

import { highLightCode } from './createCodeExamples.ts';
type CodeExampleType = {
title: string;
language: string;
code: string;
}[];
const getIconCodes = (): CodeExampleType => {
return [
{
language: 'html',
title: 'Vanilla',
code: `\
<script>
import { createIcons } from 'lucide';
import { $CamelCase } from '@lucide/lab';
createIcons({
icons: {
$CamelCase
}
});
</script>
<i data-lucide="$Name"></i>\
`,
},
{
language: 'tsx',
title: 'React',
code: `import { Icon } from 'lucide-react';
import { $CamelCase } from '@lucide/lab';
const App = () => {
return (
<Icon iconNode={$CamelCase} />
);
};
export default App;
`,
},
{
language: 'vue',
title: 'Vue',
code: `<script setup>
import { Icon } from 'lucide-vue-next';
import { $CamelCase } from '@lucide/lab';
</script>
<template>
<Icon :iconNode="$CamelCase" />
</template>
`,
},
{
language: 'svelte',
title: 'Svelte',
code: `<script>
import { Icon } from 'lucide-svelte';
import { $CamelCase } from '@lucide/lab';
</script>
<Icon iconNode={$CamelCase} />
`,
},
{
language: 'tsx',
title: 'Preact',
code: `import { Icon } from 'lucide-preact';
import { $CamelCase } from '@lucide/lab';
const App = () => {
return (
<Icon iconNode={$CamelCase} />
);
};
export default App;
`,
},
{
language: 'tsx',
title: 'Solid',
code: `import { Icon } from 'lucide-solid';
import { $CamelCase } from '@lucide/lab';
const App = () => {
return (
<Icon iconNode={$CamelCase} />
);
};
export default App;
`,
},
{
language: 'tsx',
title: 'Angular',
code: `// app.module.ts
import { LucideAngularModule } from 'lucide-angular';
import { $CamelCase } from '@lucide/lab';
@NgModule({
imports: [
LucideAngularModule.pick({ $PascalCase: $CamelCase })
],
})
// app.component.html
<lucide-icon name="$PascalCase"></lucide-icon>
`,
},
];
};
export default async function createCodeExamples() {
const codes = getIconCodes();
const codeExamplePromises = codes.map(async ({ title, language, code }, index) => {
const isFirst = index === 0;
const codeString = await highLightCode(code, language, isFirst);
return {
title,
language: language,
code: codeString,
};
});
return Promise.all(codeExamplePromises);
}