Closed wanghaisheng closed 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.
@wanghaisheng updated the docs! Hope that helpsβlet me know if you have any questions
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
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
@wanghaisheng
Here is an example using the blog template from astro with this library
Not everything is translated, but it gives an example with Content Collections. Please upgrade your astro-i18n-aut
for more utility functions
from doc, i clearly understand how to use for .astro files,but it was confused for me about .md