Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use unocss preset icons as page content icon #2669

Open
GreyXor opened this issue Jun 19, 2024 · 7 comments
Open

use unocss preset icons as page content icon #2669

GreyXor opened this issue Jun 19, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@GreyXor
Copy link

GreyXor commented Jun 19, 2024

Is your feature request related to a problem? Please describe

I try to use icon from unocss/nuxt like my other component
image
image

but in nuxt-content it's not working
image
image

Describe the solution you'd like

Icon should be showed because icon exist

  <v-list nav>
    <ContentNavigation v-slot="{ navigation }">
      <v-list-item
        v-for="link of navigation"
        :key="link._path"
        :title="link.title"
        :prepend-icon="link.icon"
        :to="link._path"
      ></v-list-item>
    </ContentNavigation>
  </v-list>

Describe alternatives you've considered

Additional context

  "devDependencies": {
    "@iconify-json/mdi": "^1.1.66",
    "@nuxt/content": "^2.12.1",
    "@unocss/nuxt": "^0.61.0",
    "nuxt": "^3.12.2",
    "vuetify-nuxt-module": "^0.14.1"
  }
@GreyXor GreyXor added the enhancement New feature or request label Jun 19, 2024
@owljackob
Copy link
Contributor

owljackob commented Jun 24, 2024

What are the values of link.title and link.icon? Did you check?

@GreyXor
Copy link
Author

GreyXor commented Jun 24, 2024

What are the values of link.title and link.icon? Did you check?

Hello, yes, link.title and link.icon have the good value", as expected it's working, and link.icon is correctly i-mdi:home. and i-mdi:home is a working icon.
You can have a look here :

---
navigation:
  title: 'i-mdi:home'
  icon: 'i-mdi:home'
---

# Dashboard

image

But if I set the icon directly like this

  <v-list nav>
    <v-list-item title="Dashboard" prepend-icon="i-mdi:home" to="/" />
  </v-list>

image

@owljackob
Copy link
Contributor

Please, try to use i-mdi-home or mdi-home instead.

What are the values of link.title and link.icon? Did you check?

Hello, yes, link.title and link.icon have the good value", as expected it's working, and link.icon is correctly i-mdi:home. and i-mdi:home is a working icon. You can have a look here :

---
navigation:
  title: 'i-mdi:home'
  icon: 'i-mdi:home'
---

# Dashboard

image

But if I set the icon directly like this

  <v-list nav>
    <v-list-item title="Dashboard" prepend-icon="i-mdi:home" to="/" />
  </v-list>

image

@GreyXor
Copy link
Author

GreyXor commented Jun 24, 2024

Please, try to use i-mdi-home or mdi-home instead.

Thank you, but it doesn't work either.

@GreyXor
Copy link
Author

GreyXor commented Jun 24, 2024

I've noticed that if (in dev) I replace :prepend-icon="link.icon" with prepend-icon="mdi-home". then it works, and if I put back (still in the same dev session) :prepend-icon="link.icon". then it still work.
It's as if the SSR icon didn't exist because it wasn't "generated".

@farnabaz
Copy link
Member

This might related to how unocss scanner acts and detects the icon names.

/cc @antfu What do you think about this issue?

@farnabaz farnabaz added bug Something isn't working and removed enhancement New feature or request labels Jul 19, 2024
@antfu
Copy link
Member

antfu commented Jul 19, 2024

UnoCSS detects usages via the transform pipeline, where in Nuxt Content, the content doesn't go into the bundler transform processor. Thus you will need to configure UnoCSS to scan from fs explicitly:
https://unocss.dev/guide/extracting#extracting-from-filesystem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants