From 3d80989e5db2fe2533bc118e8facc39e0bccdd7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Wed, 11 Nov 2026 16:02:08 +0000 Subject: [PATCH 1/2] fix(icons): register the comark icon as a custom collection The icon was added at runtime with addIcon() from @iconify/vue. A site that installs two versions of @iconify/vue registers it on one copy while @nuxt/icon renders with the other, so md and mdc code blocks had a blank icon. Register app/assets/icons through icon.customCollections instead, so the server bundle serves it, and drop the plugin and the @iconify/vue dependency. Amp-Thread-ID: https://ampcode.com/threads/T-01a1ca9f-09d0-726f-95f6-656a0f1bfefa --- app/plugins/icons.ts | 9 --------- nuxt.config.ts | 4 ++++ package.json | 1 - pnpm-lock.yaml | 3 --- test/e2e/routes.test.ts | 10 ++++++++++ 5 files changed, 14 insertions(+), 13 deletions(-) delete mode 100644 app/plugins/icons.ts diff --git a/app/plugins/icons.ts b/app/plugins/icons.ts deleted file mode 100644 index 0c8c188..0000000 --- a/app/plugins/icons.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { addIcon } from '@iconify/vue' - -export default defineNuxtPlugin(() => { - addIcon('custom:comark', { - body: '', - width: 198, - height: 198, - }) -}) diff --git a/nuxt.config.ts b/nuxt.config.ts index 9ebdd51..eea1d6e 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -65,6 +65,10 @@ export default defineNuxtConfig({ provider: 'server', fallbackToApi: 'client-only', serverBundle: { collections: LAYER_ICON_COLLECTIONS }, + // The layer's own SVGs, used as `i-custom-`. Registered at build time so the server bundle and + // SSR know them: a runtime `addIcon()` only reaches the `@iconify/vue` copy it was imported from, which is + // not the one `@nuxt/icon` renders with when a consumer installs two versions. + customCollections: [{ prefix: 'custom', dir: resolve('./app/assets/icons') }], clientBundle: { scan: true }, }, vite: { diff --git a/package.json b/package.json index fcc813f..b744c60 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,6 @@ "@iconify-json/simple-icons": "^1.2.101", "@iconify-json/unjs": "^1.2.4", "@iconify-json/vscode-icons": "^1.2.96", - "@iconify/vue": "^5.0.5", "@nuxt/kit": "^4.6.4", "@nuxt/ui": "^4.12.0", "@nuxtjs/mcp-toolkit": "^0.24.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 38d484b..743477d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -193,9 +193,6 @@ importers: '@iconify-json/vscode-icons': specifier: ^1.2.96 version: 1.2.96 - '@iconify/vue': - specifier: ^5.0.5 - version: 5.0.5(vue@3.5.44(typescript@6.0.3)) '@nuxt/kit': specifier: ^4.6.4 version: 4.6.4(@nuxt/schema@4.6.4)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.5)(mlly@1.8.2)(oxc-parser@0.153.0)(rolldown@1.2.15)(unplugin@3.7.0(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.67.5)(vite@8.3.5(@types/node@26.6.2)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.1))) diff --git a/test/e2e/routes.test.ts b/test/e2e/routes.test.ts index 0099608..bab55e5 100644 --- a/test/e2e/routes.test.ts +++ b/test/e2e/routes.test.ts @@ -72,3 +72,13 @@ describe('agent routes', () => { expect(response.headers.get('content-type')).toContain('text/markdown') }) }) + +describe('icons', () => { + // The icon of `md` code blocks is the layer's own SVG, not an Iconify collection. @nuxt/icon caches the + // JSON error of a missing icon and then answers 200 with it, so the body is what shows it is served. + it('serves the comark icon from the server bundle', async () => { + const response = await fetchPath('/api/_nuxt_icon/custom.json?icons=comark') + const collection = await response.json() as { icons?: Record } + expect(collection.icons?.comark?.body).toContain(' Date: Wed, 11 Nov 2026 16:58:48 +0000 Subject: [PATCH 2/2] fix(icons): use the comark prefix and name the icon logo A generic custom prefix clashes with a site that defines its own custom collection, since @nuxt/icon keys the server bundle by prefix. The layer's icon is now i-comark-logo, from app/assets/icons/logo.svg. Amp-Thread-ID: https://ampcode.com/threads/T-01a1ca9f-09d0-726f-95f6-656a0f1bfefa --- app/app.config.ts | 4 ++-- app/assets/icons/{comark.svg => logo.svg} | 0 app/components/content/landing/LandingHeroDemo.vue | 2 +- nuxt.config.ts | 4 ++-- test/e2e/routes.test.ts | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) rename app/assets/icons/{comark.svg => logo.svg} (100%) diff --git a/app/app.config.ts b/app/app.config.ts index f8f3046..a7cbb1a 100644 --- a/app/app.config.ts +++ b/app/app.config.ts @@ -126,8 +126,8 @@ export default defineAppConfig({ 'next.config.ts': 'i-simple-icons-nextjs', astro: 'i-simple-icons:astro', nitro: 'i-unjs-nitro', - md: 'i-custom-comark', - mdc: 'i-custom-comark', + md: 'i-comark-logo', + mdc: 'i-comark-logo', react: 'i-logos-react', html: 'i-vscode-icons-file-type-html', svelte: 'i-logos-svelte-icon', diff --git a/app/assets/icons/comark.svg b/app/assets/icons/logo.svg similarity index 100% rename from app/assets/icons/comark.svg rename to app/assets/icons/logo.svg diff --git a/app/components/content/landing/LandingHeroDemo.vue b/app/components/content/landing/LandingHeroDemo.vue index fccb9fd..5d2e64f 100644 --- a/app/components/content/landing/LandingHeroDemo.vue +++ b/app/components/content/landing/LandingHeroDemo.vue @@ -15,7 +15,7 @@ const plugins = [rangi({ theme: geistTheme })] const sourceAsCode = computed(() => ['````md', props.source, '````'].join('\n')) const tabs = [ - { id: 'source', label: 'source.md', icon: 'i-custom-comark' }, + { id: 'source', label: 'source.md', icon: 'i-comark-logo' }, { id: 'output', label: 'preview', icon: 'i-lucide-eye' }, ] const activeIndex = ref(0) diff --git a/nuxt.config.ts b/nuxt.config.ts index eea1d6e..4a58c39 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -65,10 +65,10 @@ export default defineNuxtConfig({ provider: 'server', fallbackToApi: 'client-only', serverBundle: { collections: LAYER_ICON_COLLECTIONS }, - // The layer's own SVGs, used as `i-custom-`. Registered at build time so the server bundle and + // The layer's own SVGs, used as `i-comark-`. Registered at build time so the server bundle and // SSR know them: a runtime `addIcon()` only reaches the `@iconify/vue` copy it was imported from, which is // not the one `@nuxt/icon` renders with when a consumer installs two versions. - customCollections: [{ prefix: 'custom', dir: resolve('./app/assets/icons') }], + customCollections: [{ prefix: 'comark', dir: resolve('./app/assets/icons') }], clientBundle: { scan: true }, }, vite: { diff --git a/test/e2e/routes.test.ts b/test/e2e/routes.test.ts index bab55e5..f86a5b2 100644 --- a/test/e2e/routes.test.ts +++ b/test/e2e/routes.test.ts @@ -76,9 +76,9 @@ describe('agent routes', () => { describe('icons', () => { // The icon of `md` code blocks is the layer's own SVG, not an Iconify collection. @nuxt/icon caches the // JSON error of a missing icon and then answers 200 with it, so the body is what shows it is served. - it('serves the comark icon from the server bundle', async () => { - const response = await fetchPath('/api/_nuxt_icon/custom.json?icons=comark') + it('serves the comark logo from the server bundle', async () => { + const response = await fetchPath('/api/_nuxt_icon/comark.json?icons=logo') const collection = await response.json() as { icons?: Record } - expect(collection.icons?.comark?.body).toContain('