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

Multisite not working with language in path #5

Open
maximepalau opened this issue Apr 2, 2020 · 3 comments
Open

Multisite not working with language in path #5

maximepalau opened this issue Apr 2, 2020 · 3 comments

Comments

@maximepalau
Copy link

maximepalau commented Apr 2, 2020

Hi,

I'm experiencing an issue with the multisite logic.

I’m using nuxt-i18n to manage the languages of my application. For a same page in two different languages, the URLs are like the following:

The issue is that, when I do have a /fr prefix in my route, that prefix is sent to SEOmatic via the uri parameter (see screenshot below), and because of this SEOmatic cannot find the related entry. Craft does not include the language in the URIs of the pages. When I remove this prefix manually, it works.

Screenshot 2020-04-02 at 10 19 17

This is what I did (in a simplified version) to make it work:

let fullPath = route.fullPath;

if (fullPath.startsWith('/fr')) {
     fullPath = route.fullPath.replace('/fr/', '/');
}

return await app.seomaticMeta({ fullPath }, siteId);

I guess we can agree this is not a sustainable solution. Is there a way (with the current methods/configuration elements) to indicate to the plugin the languages to remove from the path for all the pages? Would it be possible to implement that feature otherwise?

@ben-rogerson
Copy link
Owner

Hey sorry for the late reply.
Yeah should be possible to do - If you'd like to submit a PR with the functionality I'd be more than happy to review 👍

@toddpadwick
Copy link

@maximepalau @ben-rogerson I am trying to do the same - did you find a solution for this? I also have another issue related - how would I get the siteId from the siteHandle (eg fr)? the only data I will have to determine which site I am on is from the locale/handle so there's no way of me knowing what the ID is.

async asyncData (context) {
      const siteHandle = context.app.i18n.locale;
      const siteId = 1; // how do I get the siteId from the siteHandle?
      return {
          headData: await context.app.seomaticMeta(context.route, siteId),
      }
  },

@ben-rogerson
Copy link
Owner

Great question, I'd like to know this too.
A quick google brings this function: craft.app.getSites().getSiteByHandle('handle')
But the I wonder how you'd grab that from within nuxt?

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

3 participants