Nuxt generate:before: the url key is not generated

Hello,

I have a problem with the apiOptions.routes in the Prismic module.
The generator hook is launched but in no document I have the url property. Could it be that it's not deployed on the cluster I'm using? Or a problem with my configuration

Running "@nuxtjs/prismic": "^1.2.4"
See here my nuxt.config.js file.
I also tried with a simpler setup but it doesn't work

export default {
  // Target (https://go.nuxtjs.dev/config-target)
  target: 'static',

  // Src directory (https://nuxtjs.org/guides/configuration-glossary/configuration-srcdir)
  srcDir: 'src/',

  // Global page headers (https://go.nuxtjs.dev/config-head)
  head: {
    title: 'Prismea',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
  },

  // Global CSS (https://go.nuxtjs.dev/config-css)
  css: [],

  // Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
  plugins: [],

  // Auto import components (https://go.nuxtjs.dev/config-components)
  components: true,

  // Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
  buildModules: [
    // https://go.nuxtjs.dev/typescript
    '@nuxt/typescript-build',
    // https://go.nuxtjs.dev/stylelint
    '@nuxtjs/stylelint-module',
  ],

  // Modules (https://go.nuxtjs.dev/config-modules)
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
    '@nuxtjs/prismic',
  ],

  prismic: {
    endpoint: 'https://prismea-dev.cdn.prismic.io/api/v2',
    apiOptions: {
      routes: [
        {
          type: 'homepage',
          path: '/',
        },
        {
          type: 'page',
          path: '/:leve1?/level2?/:uid',
          resolvers: {
            level1: 'parent_page',
            level2: 'parent_page.parent_page',
          },
        },
        {
          type: 'blog_home',
          path: '/:uid',
        },
        {
          type: 'blog_post',
          path: '/:level1?/:uid',
          resolvers: {
            parent: 'parent_page',
          },
        },
      ],
    },
  },

  router: {
    extendRoutes(routes, resolve) {
      routes.push({
        name: 'recursive-page',
        path: '/:level1?/:level2?/:uid',
        component: resolve(__dirname, 'src/pages/_uid.vue'),
      });
    },
  },

  // Axios module configuration (https://go.nuxtjs.dev/config-axios)
  axios: {},

  // Build Configuration (https://go.nuxtjs.dev/config-build)
  build: {},

  loading: {
    color: '#c95469',
    height: '5px',
  },
};

Thanks :grinning:

Hello Jérémy, welcome to the forum!

Yes, it probably was the cluster that your repo was using. Could you try again now and let me know it the URLs work now?

1 Like

Hello Paulina, thanks for your response :slightly_smiling_face:

Indeed, my repository should be on a cluster that does not support the new APIResolver, now it works !

But I have a problem. I would like to be able to handle 3 depth URLs on the same custom type.
And the Nuxt Prismic generate:before hook returns as a response for some documents

{
  uid: 'createur-entreprise',
  url: '/decouvrir-nos-forfaits/level2',
  type: 'page',
},

Here, I would like as url : /my-fisrt-page/my-second-page/my-third-page but it doesn't work

// API response
const doc = {
  // ...
  uid: 'my-third-page',
  data: {
    parent_page: {
      // ...
      uid: 'my-second-page',
      data: {
        parent_page: {
          // ...
          uid: 'my-fisrt-page',
        },
      },
    },
  },
};

// nuxt.config.js
prismic: {
    endpoint: process.env.PRISMIC_ENDPOINT,
    apiOptions: {
      routes: [
        // ...
        {
          type: 'page',
          path: '/:level1?/level2?/:uid',
          resolvers: {
            level1: 'parent_page',
            level2: 'parent_page.parent_page',
          },
        },
      ],
    },
  },

I also tested this option there but the API response was {"message":"[Link resolver error] The resolver level2 can only resolve a document link 2 level deep."}

apiOptions: {
  routes: [
    // ...
    {
       // ...
       resolvers: {
         // ...
         level2: 'parent_page.data.parent_page',
       },
     }
  ],
},

So my question, is it possible to do depth recursion on a custom type with the new API resolver?
Or will it be in the future?

Thanks :slight_smile:

Hey Jérémy, are you still having this issue?

I just took a closer look to your configuration and seems like you're missing a : in the routes.path section?

In your config:

path: '/:level1?/level2?/:uid',

Correct config?

path: '/:level1?/:level2?/:uid',

Hey Paulina.

Thank you for your reply.
Indeed, you're right, the colon was missing

Thanks :slight_smile: Havea good day !

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.