-
I'm in the making of a multilingual (EN, ES) website with a blog in Astro js, with Decap CMS for the blog posts and astro-i18next for its internationalisation features. I'm having problems to find out how to get this to work right. This astro site is setup with EN as default language and ES as secondary. Here is the page structure:
Thanks to the astro-i18next config I can, for example, route the Spanish about to website.com/es/quien-somos. Now, I've setup Decap CMS to create multilingual blog posts. But when I create a new post through the admin panel, it creates the md files in folders for each language, also for the default language:
So, my problem related to Decap CMS is that it isn't following the file structure of setup in the i18n config.
Can someone give me some tips on how I could route that the right way? I mean, not hard coded in the i18next config file, with through some dynamic routing magic. That is that:
Thx! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
At the end, I could make a solution through routing. The main idea is to have post routes based on the post titles (in each language). Utility SnippetFirst, in utils.ts, I copy a small snippet from https://www.30secondsofcode.org/js/s/string-to-slug/
I will be using this extendly. Post index pageNext, for
Single Post pages (with dynamic routes)Then, I create the file for the single posts
Nav BarBecause I can't use the i18next config file for my post routes, I've to create an extra function to get the paths to the translations based on the titles and slugs.
Now I can just use the value of ^_^ |
Beta Was this translation helpful? Give feedback.
At the end, I could make a solution through routing. The main idea is to have post routes based on the post titles (in each language).
Utility Snippet
First, in utils.ts, I copy a small snippet from https://www.30secondsofcode.org/js/s/string-to-slug/
I will be using this extendly.
Post index page
Next, for
pages/blog/index.astro
, I filter for all posts in needed language and create the post urls based on the slugified post title. Because Decap CMS saves each post with the same file name but in folders…