Skip to content

Decap CMS + Internationalization (i18n > astro-i18next) #7258

Answered by quasiDigi
quasiDigi asked this question in Q&A
Discussion options

You must be logged in to vote

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/

export const slugify = (str: string) =>
    str
        .toLowerCase()
        .trim()
        .replace(/[^\w\s-]/g, '')
        .replace(/[\s_-]+/g, '-')
        .replace(/^-+|-+$/g, '');

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…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by quasiDigi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant