Generate issue with cyrillic languages

Hi,

we have an issue with nuxt generate on the cyrillic locales.

The issue: On the first click on any link, the url and page changes; on the second not so. The content of the first link is staying, while the url changes.

This is what we tried:

  • Decoding URLs on all websites does not work.
  • Decoding strings in requests for Prismic does not work.
  • Decreased languages, we tried to decrease the number of languages only leaving two base languages and all Cyrillic languages but not work.
  • We checked all Vue components for building URL structure and didn't find issues.
  • We checked all queries (we didn't change queries for more than 1 year ) and didn't find any issues.

P.S. Everything works fine in local env on SPA and the build doesn't have errors, this issue is only on live env.

Hi @aleksandar.basara1 ,

Can you show the code for the link that leads to this page? It maybe sounds like an issue I've dealt with before

/**
 * To learn more about Link Resolving check out the Prismic documentation
 * https://prismic.io/docs/vuejs/beyond-the-api/link-resolving
 */
import helpers from "@/app/develop/helpers.js";

import configs from "@/configs/main.config";
const getHomeSlug = (lang)=>{
  //  let returnSlash = false;
  //  for (let index = 0; index < Object.values(configs).length; index++) {
  //     const element = Object.values(configs)[index];
  //     if(element.language == lang) returnSlash = true;
  //  }
   return `${lang}/`;
}
export default function (doc) {
  if (doc.isBroken) {
    return "/404/";
  }

  if (doc.link_type == "Web") {
    return doc.url;
  }

  if (doc.link_type == "Media") {
    return doc.url;
  }

  if (doc.type === "homepage") {
    return `/${getHomeSlug(doc.lang)}`;
  }

  const postTypes = helpers.getPostType(null, doc.lang);
  for (let index = 0; index < postTypes.length; index++) {
    const item = postTypes[index];
    if (doc.type == item.type) {
      let slug = item.slug;
      // Post type with parent
      if (doc.data && doc.data.parent && doc.data.parent.uid) {
        return `/${doc.lang}/${doc.data.parent.uid}/${
          doc.uid
        }/`;
      }

      if (slug == null) {
        return `/${doc.lang}/${doc.uid}/`;
      }
      // Default URL
      return `/${doc.lang}/${slug}/${doc.uid}/`;
    }
  }
  return "/404/";
}

This looks like your custom link resolver,

But can you show me the Prismic Link component that is consuming this link resolver code?

this one?

I think you forgot to paste the code :sweat_smile:

Damn :slight_smile:

<script>
import helpers from "@/app/develop/helpers.js";
import defaultValues, { getDomain } from "../../configs/defaultValues";
import linkResolver from "../../app/prismic/link-resolver";
export default {
   props: ["doc", "title", "cssClass"],
   data() {
      return { nuxtLink: false, link: null, styleClass: {} }
   },
   created() {
      const postTypes = helpers.getPostType(null, this.doc.lang);
      const values = defaultValues(this.$config.domainLang);
      if (this.doc.lang && (values.language == this.doc.lang || values.languages.includes(this.doc.lang))) {
         if (this.doc.type == "homepage") {
            this.nuxtLink = true;
         }
         for (let index = 0; index < postTypes.length; index++) {
            const item = postTypes[index];
            if (this.doc.type == item.type) {
               this.nuxtLink = true;
            }
         }
      }
      // if (this.doc.link_type == "Web" || this.doc.link_type == "Media") {
        
      // } else {
      //    this.link = `${this.nuxtLink ? "" : getDomain(this.doc.lang)}${linkResolver(this.doc)}`;
      // }
       this.link = `${linkResolver(this.doc)}`;
   },
   template: `<nuxt-link v-if="nuxtLink" :to="link" data-custom-link-nuxt  :class="cssClass" :title="title"><slot></slot></nuxt-link> <a v-else :href="link" data-custom-link :class="cssClass" :title="title"><slot></slot></a>`
}
</script>

Thanks for sending me this.

Can you try building your links with the recommended prismic-link component (it extends nuxt-link) provided by the prismic-nuxt package? Hopefully, your links will work then.

We are using still nuxt 2and all the other languages are working fine.

Prismic-link is available in Nuxt 2 as well

We did a test, and it is still an issue.

What changes did you make?

Do you have errors in your console or terminal?

Can you show me screenshots of the issue?

How can I send you a Loom as a DM?

Thanks for sending me the video. I've been looking at it for a while and it seems like something I've seen before. I'll get back to you when I figure it out.

So the link resolver seems to be working correctly. Can you send me the complete code you're doing, including the queries for these pages that aren't loading when you hit the URL?

You can send it in the private message if need be.

So I think it sounds like this issue that was happening here. Does that look correct?

I've send you a dm

Thank you. Does the above thread sound like your issue?

Not really, it is working on other languages without any issue.

Any ideas?