nuxt / nuxt/icon

Using local collection.json

Open
#352 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.2k
Forks
96
Avg merge
8h 12m
Merged PRs (30d)
2

Description

Is it possible to use a collection that is inside my project's assets?
I have a JSON in the IconifyJSON format. It would be nice if it's somehow possible to import a custom IconifyJSON.

my custom collection:

{
  "prefix": "ti",
  "info": {
    "name": "Telekom",
    "total": 742,
    "version": "1.0.0",
    "author": {
      "name": "",
      "url": ""
    },
    "samples": [],
    "category": "Custom",
    "tags": [],
    "palette": false
  },
  "lastModified": 1738666400,
  "icons": {
    "add-default": {
      "body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<svg width=\"24px\" height=\"24px\" viewBox=\"0 0 24 24\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n    <title>/svg/icon/action",
      "width": 24,
      "height": null
    },

I was trying to do it like this:

import tailwindcss from "@tailwindcss/vite";
import { createResolver } from "@nuxt/kit";

const { resolve } = createResolver(import.meta.url);
export default defineNuxtConfig({
  compatibilityDate: "2024-11-01",
  icon: {
    customCollections: resolve("./assets/icons/collections.json"),
  },
  modules: ["nuxt-icon-tw"],
  css: ["~/assets/styles/main.pcss"],
  postcss: {
    plugins: {
      "postcss-nested": {},
      "@tailwindcss/postcss": {},
    },
  },
  vite: {
    plugins: [tailwindcss()],
  },
});

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Nuxt configuration shown in the issue and the assets/icons/collections.json path it passes to customCollections. Determine how a local IconifyJSON collection is expected to be loaded, then verify that an icon from the custom collection renders through the Nuxt icon module. No test file or entry point is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.