jlarmstrongiv / astro-i18n-aut

The i18n integration for Astro πŸ§‘β€πŸš€
https://www.npmjs.com/package/astro-i18n-aut
MIT License
125 stars 12 forks source link

if use this one ,how to deal with .md blog #8

Closed wanghaisheng closed 1 year ago

wanghaisheng commented 1 year ago

from doc, i clearly understand how to use for .astro files,but it was confused for me about .md

jlarmstrongiv commented 1 year ago

@wanghaisheng this library does not support markdown in the /pages directory.

I encourage you to separate your markdown content from your astro pages that have the styling and logic.

Instead, for markdown, I recommend using Astro with its Content Collections:

Here’s an example project structure:

.
└── astro-project/
    └── src/
        β”œβ”€β”€ pages/
        β”‚   └── blog/
        β”‚       β”œβ”€β”€ index.astro
        β”‚       └── [id].astro
        └── content/
            └── blog/
                β”œβ”€β”€ en/
                β”‚   β”œβ”€β”€ post-1.md
                β”‚   └── post-2.md
                β”œβ”€β”€ es/
                β”‚   β”œβ”€β”€ post-1.md
                β”‚   └── post-2.md
                └── fr/
                    β”œβ”€β”€ post-1.md
                    └── post-2.md

That way, all your posts are organized with all your languages, and you have a single blog page to list posts and individual page for each post.

Then, you can use your locale from this library along with getCollection and getEntry, and render the contents in your Astro files.

So all your locales will use the same astro template, even with a default locale.

Let me know if you have any questions! I will update the README with this information too.

jlarmstrongiv commented 1 year ago

@wanghaisheng updated the docs! Hope that helpsβ€”let me know if you have any questions

wanghaisheng commented 1 year ago

I finally get that i am use content/*.md now let me try

@jlarmstrongiv

we must put blog content under each language folder?

└── astro-project/ └── src/ β”œβ”€β”€ pages/ β”‚ └── blog/ β”‚ β”œβ”€β”€ index.astro β”‚ └── [id].astro └── content/ └── blog/ β”‚ β”œβ”€β”€ post-1.md β”‚ └── post-2.md β”œβ”€β”€ en/ β”‚ β”œβ”€β”€ post-1.md β”‚ └── post-2.md β”œβ”€β”€ es/ β”‚ β”œβ”€β”€ post-1.md β”‚ └── post-2.md └── fr/ β”œβ”€β”€ post-1.md └── post-2.md

wanghaisheng commented 1 year ago

Then, you can use your locale from this library along with getCollection and getEntry, and render the contents in your Astro files.

can you show a example for this

jlarmstrongiv commented 1 year ago

@wanghaisheng

Here is an example using the blog template from astro with this library

astro-i18n-blog.zip

Not everything is translated, but it gives an example with Content Collections. Please upgrade your astro-i18n-aut for more utility functions