Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wanghaisheng opened this issue Jul 11, 2023 · 5 comments
Closed

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

wanghaisheng opened this issue Jul 11, 2023 · 5 comments

Comments

@wanghaisheng
Copy link

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

@jlarmstrongiv
Copy link
Owner

@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
Copy link
Owner

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

@wanghaisheng
Copy link
Author

wanghaisheng commented Jul 11, 2023

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
Copy link
Author

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
Copy link
Owner

jlarmstrongiv commented Jul 11, 2023

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants