Giter Site home page Giter Site logo

Comments (3)

mccrodp avatar mccrodp commented on June 27, 2024 1

Ahh, interesting use case. That's one for upstream and not for this starter though. I suggest you open a ticket on how to achieve slug localisation in https://github.com/angeloocana/gatsby-plugin-i18n and see if you can get any insights there. All the best. Closing this but feel free to reopen if there's anything specific remaining on this starter.

from gatsby-starter-contentful-i18n.

mccrodp avatar mccrodp commented on June 27, 2024

Hey @MartinConde, thanks for using this starter. There sure is, you just create a "Slug" field in Contentful and use that in your gatsby.node.js file. This starter just uses the contentful_id as I do not have access to the source CMS 😄 It uses the same one as the regular Contentful demo for consistency.

Hope this helps: https://github.com/ahimsayogajp/ahimsayoga-gatsby/blob/master/gatsby-node.js#L49

from gatsby-starter-contentful-i18n.

MartinConde avatar MartinConde commented on June 27, 2024

Hi thank you for creating the starter ;)

That's what I did but forgot that I had localized the slug field as well that's why the language switcher didn't work.

Hope you don't mind me throwing in my "feature wishes" for this starter in here. Really only one thing that would make it perfect for me:

Localized urls and if possible even localized slugs although I guess the latter one will be quite tricky. Will play around with https://www.gatsbyjs.org/packages/gatsby-plugin-intl-url/ a bit see if I can get something working but I'm pretty sure your solution would be more robust than mine haha.

EDIT
Tried integrating the gatsby-plugin-intl-url package but it's beyond my knowledge as there is duplicate functionality and I end up with routes having double locales like site.com/en/en/about.

However I found a way which I am sure is not very elegant but seems to create the correct routes:

I have a content type Animal, to which I added a textfield "route" and enabled localization on it.
Then in gatsby-node.js I just added it to the path

...
const animalroute = edge.node.route
...
path: /${edge.node.node_locale}/${animalroute}/${edge.node.slug},
...

When I check allSitePage in the GraphiQl it does indeed generate the correct routes :) Now I only gotta figure out how to make a different lang switcher for those pages.

from gatsby-starter-contentful-i18n.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.