Comments (3)
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.
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.
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)
- Node ID is currently used in slug, so is split to be common over both languages HOT 1
- Investigate Converting TemplateWrapper to Component that extends React.Component HOT 3
- Add "Deploy to Netlify" button HOT 1
- Update README to include how to install and run HOT 1
- Content on dynamic pages reverts to id on built versions HOT 13
- Make the choice of language persistent across pages HOT 2
- Add ui-string handling via contentful HOT 1
- Installation problems HOT 2
- Question: Do I have to copy two versions of every page? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gatsby-starter-contentful-i18n.