nuxt-modules / prismic

Easily connect your Nuxt.js application to your content hosted on Prismic
https://prismic.nuxtjs.org
MIT License
245 stars 48 forks source link

Endpoint option is required #199

Closed luca-smartpricing closed 1 year ago

luca-smartpricing commented 1 year ago

Versions

Reproduction

https://stackblitz.com/edit/github-9j4ub2?file=nuxt.config.ts

What is Expected?

Removing the enpoint option in defineNuxtConfig.prismic in favor of createClient() in /app/prismic/client.ts doesn't work. (but in my project routes: [] option in createClient() it works. So i declared two repository endpoint to be able to use routes: [])

lihbr commented 1 year ago

Hey there, thanks for contributing!

Currently, it's mandatory to provide the endpoint separately no matter if a specific client is also provided for the module to work (it's used to inject the toolbar correctly).

It might be possible to infer it from the client in plugins, however, so I'll switch this issue to a "feature request" / "enhancement" if that's fine with you!

In the meantime, you can provide routes to your client without being required to declare a dedicated one (should be all typed):

export default defineNuxtConfig({
  prismic: {
    clientConfig: {
      routes: [
        // Resolves Page documents to URLs like "/about" and "/blog"
        {
          type: "page",
          path: "/:uid",
        },
      ],
    },
  },
});

See the documentation for more examples: https://prismic.io/docs/nuxt-3-define-routes#define-routes

lihbr commented 1 year ago

Released in 3.1.0: https://github.com/nuxt-modules/prismic/blob/master/CHANGELOG.md#user-content-310-2023-10-24

luca-smartpricing commented 1 year ago

Wow, thanks for the update!