Wrong URL with PrismicLink

Hi!

On my SliceMachine, i created a Link field:

On prismic, the client has linked to another Page (uid : contact)

On my HTML:

<PrismicLink :field="slice.primary.btn_link" tab-index="-1" class="button">
    {{ slice.primary.btn_label}}
</PrismicLink>

But when rendering (i displayed the {{ slice.primary.btn_linkg }} above)

Any ideas?

Thanks a lot!
Vincent

Hi Vincent,

I don't quite understand what the problem is.

I can see that the link UID is contact which is the linked document in Prismic.

What is your expected behaviour? :slight_smile:

Indeed, but the link of the button is not contact :(

Ah sorry yes!

have you setup a link resolver?

can you share your route resolver too?

That'll likely be why it's linking to another document.

Hi Jake,

I haven't any Link Resolver.
It's not linking to another document, it's the slug of the actual page, where the button is.

My code:

<PrismicLink :field="slice.primary.btn_link" tab-index="-1" class="button">
    {{ slice.primary.btn_label}}
</PrismicLink>

HTML Render:

<a tab-index="-1" href="" class="button">
      Contacter l'agence pour en discuter
 </a>

I juste create some Routes Resolver for dynamic pages / slug:

prismic: {
    endpoint: apiEndpoint,
    modern: true,
    /* see configuration for more */
    apiOptions: {
      routes: [
        // Resolves the Homepage document to "/"
        {
          type: 'homepage',
          path: '/',
        },
        {
          type: 'article',
          path: '/blog/:category/:uid',
          resolvers: {
            category: 'category'
          }
        },
        {
          type: 'client',
          path: '/cas-clients/:uid'
        },
        {
          type: 'landing_page',
          path: '/:category/:uid',
          resolvers: {
            category: 'category'
          }
        },
      ],
    },
  },

The Contact Page is a simple page, i don't understand :frowning:
(thanks for your time :wink: )

Ok thanks Vincent

Try adding another route resolver rule for your new document type

{
  type: 'pagecontent',
  path: '/:uid'
}

Let me know how you get on :)

:sweat_smile:

I'm think i'm stupid!
It was just that...
Thanks a lot!

1 Like