-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add utility function to localize path + improve components and …
…overall DX - update utility functions + add unit tests - reduce required config options to get started - add about page + navigation to example - improve responsive on example website - rename github workflows - add badges to README.md - update documentation BREAKING CHANGE: rename i18nextConfig to i18next in config + remove className and baseLanguage props for LanguageSelector
- Loading branch information
1 parent
505185e
commit d230f00
Showing
32 changed files
with
612 additions
and
198 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Build and Deploy Example | ||
name: astro-i18next-deploy-example | ||
|
||
on: | ||
push: | ||
|
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
--- | ||
const { ...attributes } = Astro.props; | ||
const { class: className, ...attrs } = attributes; | ||
--- | ||
|
||
<a | ||
class={`transition shadow-lg hover:shadow-md hover:shadow-cyan-500/30 shadow-cyan-500/40 py-3 px-5 bg-gradient-to-b from-cyan-50 to-cyan-200 rounded-full font-semibold uppercase text-cyan-900 border-b-2 border-t-2 border-t-white border-b-cyan-400 focus:ring-2 tracking-wider ${className}`} | ||
{...attrs} | ||
><slot></slot> | ||
</a> |
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,9 @@ | ||
--- | ||
const { ...attributes } = Astro.props; | ||
--- | ||
|
||
<a | ||
class="underline hover:no-underline decoration-4 decoration-cyan-500" | ||
{...attributes} | ||
><slot></slot> | ||
</a> |
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,32 @@ | ||
--- | ||
import i18next, { t } from "i18next"; | ||
import { localizePath } from "astro-i18next"; | ||
const { ...attributes } = Astro.props; | ||
const { pathname } = Astro.canonicalURL; | ||
const navigationItems = { | ||
"/": t("navigation.home"), | ||
"/about/": t("navigation.about"), | ||
}; | ||
--- | ||
|
||
<nav class="py-2 mt-2 flex gap-x-2" {...attributes}> | ||
{Object.keys(navigationItems).map((key) => { | ||
let className = | ||
"py-2 px-4 uppercase text-sm underline-offset-2 tracking-wider decoration-4 font-semibold" | ||
|
||
if (localizePath(key, i18next.language) === pathname) { | ||
className += " underline decoration-cyan-500 " | ||
} else { | ||
className += | ||
" opacity-75 hover:opacity-100 hover:underline decoration-gray-300" | ||
} | ||
|
||
return ( | ||
<a class={className} href={localizePath(key, i18next.language)}> | ||
{navigationItems[key]} | ||
</a> | ||
) | ||
})} | ||
</nav> |
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,33 @@ | ||
--- | ||
import { SEO } from "astro-seo"; | ||
import { t } from "i18next"; | ||
const { href: canonicalUrl } = Astro.canonicalURL; | ||
--- | ||
|
||
<link rel="icon" type="image/x-icon" href="/favicon.ico" /> | ||
<SEO | ||
title={t("seo.title")} | ||
description={t("seo.description")} | ||
canonical={canonicalUrl} | ||
openGraph={{ | ||
basic: { | ||
title: t("seo.ogTitle"), | ||
description: t("seo.description"), | ||
type: "website", | ||
image: | ||
"https://astro-i18next.yassinedoghri.com/assets/images/open-graph.jpg", | ||
url: canonicalUrl, | ||
}, | ||
image: { | ||
alt: t("seo.ogImageAlt"), | ||
width: "1200", | ||
height: "630", | ||
type: "image/jpeg", | ||
}, | ||
}} | ||
twitter={{ | ||
card: "summary_large_image", | ||
creator: "@yassinedoghri", | ||
}} | ||
/> |
Oops, something went wrong.