-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Luiz Ferraz <[email protected]>
- Loading branch information
1 parent
d01908c
commit 8bc6c8e
Showing
44 changed files
with
1,489 additions
and
790 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@astrolicious/i18n": minor | ||
--- | ||
|
||
Adds a new `getDefaultLocalePlaceholder` utility |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@astrolicious/i18n": minor | ||
--- | ||
|
||
Adds Content Collections helpers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@astrolicious/i18n": minor | ||
--- | ||
|
||
Adds sitemap support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,6 @@ | |
} | ||
}, | ||
"files": { | ||
"ignore": ["dist", ".astro"] | ||
"ignore": ["dist", ".astro", ".netlify"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ pnpm-debug.log* | |
|
||
# macOS-specific files | ||
.DS_Store | ||
|
||
.netlify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"home": "Home", | ||
"hero": "Benvenuti alla demo di I18n per Astro", | ||
"footer": "Fatto con il ❤️ da astrolicious", | ||
"about": "Chi siamo", | ||
"aboutMessage": "Questa è una pagina semplice", | ||
"opensource": "Lo sapevi che questa pagina è disponibile su GitHub? No? Beh, ora lo sai!", | ||
"opensourceCTA": "Vai a dare un'occhiata!", | ||
"blog": "Blog" | ||
} | ||
"home": "Home", | ||
"hero": "Benvenuti alla demo di I18n per Astro", | ||
"footer": "Fatto con il ❤️ da astrolicious", | ||
"about": "Chi siamo", | ||
"aboutMessage": "Questa è una pagina semplice", | ||
"opensource": "Lo sapevi che questa pagina è disponibile su GitHub? No? Beh, ora lo sai!", | ||
"opensourceCTA": "Vai a dare un'occhiata!", | ||
"blog": "Blog" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
title: Sitemap | ||
--- | ||
|
||
To enable the sitemap, set the `sitemap` option of the integration config to `true` or an object: | ||
|
||
```ts title="astro.config.mjs" ins={3} | ||
i18n({ | ||
// ... | ||
sitemap: true // or {} | ||
}) | ||
``` | ||
|
||
After you run `astro sync`, you'll be able to import a new function from `i18n:astro/sitemap` on your Astro pages: | ||
|
||
```astro | ||
--- | ||
import sitemap from "i18n:astro/sitemap" | ||
--- | ||
``` | ||
|
||
This allows you to set specific params at the route level. It's really interesting to generate i18n friendly sitemaps (with alternates): | ||
|
||
```ts | ||
import { getCollection } from "astro:content"; | ||
import { | ||
getLocalePlaceholder, | ||
getDefaultLocalePlaceholder, | ||
setDynamicParams, | ||
} from "i18n:astro"; | ||
import sitemap from "i18n:astro/sitemap"; | ||
import { | ||
collectionFilters, | ||
generateDynamicParams, | ||
handleI18nSlug, | ||
} from "@astrolicious/i18n/content-collections"; | ||
import type { GetStaticPaths } from "astro"; | ||
|
||
export const getStaticPaths = (async () => { | ||
const locale = getLocalePlaceholder(); | ||
const defaultLocale = getDefaultLocalePlaceholder(); | ||
|
||
const posts = await getCollection("posts", (post) => | ||
collectionFilters.byLocale(post, { locale }), | ||
); | ||
|
||
return await Promise.all( | ||
posts.map(async (post) => { | ||
const equivalentPosts = await getCollection("posts", (p) => | ||
collectionFilters.matchingEntries(p, { | ||
currentEntry: post, | ||
key: "defaultLocaleVersion", | ||
locale, | ||
defaultLocale, | ||
}), | ||
); | ||
|
||
const dynamicParams = equivalentPosts.map((entry) => { | ||
const { locale, slug } = handleI18nSlug(entry.slug); | ||
|
||
return { | ||
locale, | ||
params: { | ||
slug, | ||
}, | ||
}; | ||
}); | ||
|
||
sitemap({ | ||
dynamicParams, | ||
}); | ||
|
||
return { | ||
params: { | ||
slug: handleI18nSlug(post.slug).slug, | ||
}, | ||
props: { | ||
post, | ||
dynamicParams, | ||
}, | ||
}; | ||
}), | ||
); | ||
}) satisfies GetStaticPaths; | ||
|
||
const { post, dynamicParams } = Astro.props; | ||
|
||
setDynamicParams(dynamicParams); | ||
``` |
Oops, something went wrong.