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

Custom provider errors on nuxt-ui:3.0.0-alpha.6 #342

Open
kofeinstyle opened this issue Oct 17, 2024 · 0 comments
Open

Custom provider errors on nuxt-ui:3.0.0-alpha.6 #342

kofeinstyle opened this issue Oct 17, 2024 · 0 comments

Comments

@kofeinstyle
Copy link

kofeinstyle commented Oct 17, 2024

A few days ago, I installed version nuxt-ui:3.0.0-alpha.6, and when I tried to connect my provider as described in the Nuxt Fonts documentation, I encountered build errors.

I conducted an experiment on a clean project and got the same result. Where is my mistake? Or is it a documentation mistake?

Image

nuxt.config.ts

export default defineNuxtConfig({
  compatibilityDate: '2024-04-03',
  devtools: { enabled: true },
  modules: [
    '@nuxt/ui',
  ],
  fonts: {
    experimental: {
    //   // Required for TailwindCSS v4. You can enable support for processing CSS variables for font family names. This may have a performance impact.
      processCSSVariables: true,
    },
    providers: {
      // You can pass a new custom provider - see more in the providers documentation
      // for what this file should look like
      custom: '~/providers/custom',
    },
  },
})

custom.ts

import { defineFontProvider } from 'unifont';

export default defineFontProvider('custom', async (options) => {
    // do some setup
    return {
      async resolveFont (fontFamily, options) {
      
        if (fontFamily === 'TT Fors') {
          return {
            fonts: [
              {
                src: [
                  { url: '//my-cdn.cloudfront.net/fonts/TTFors/TTFors-Medium.woff2', format: 'woff2' },
                ],
                weight: 500,
                style: 'normal',
              }
            ]
          }
        }
      }
    }
  })

package.json

{
  "name": "nuxt-app",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "dependencies": {
    "@nuxt/ui": "^3.0.0-alpha.6",
    "nuxt": "^3.13.0",
    "vue": "latest",
    "vue-router": "latest"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant