Skip to content

Commit

Permalink
fix(language-selector): replace country-code-to-flag-emoji dependency…
Browse files Browse the repository at this point in the history
… with locale-emoji

- bump astro to latest version (1.0.0-rc.7)
- replace deprecated Astro.canonicalURL with Astro.url
- update packages to latest versions

closes #14
  • Loading branch information
yassinedoghri committed Aug 7, 2022
1 parent e297d7d commit 3a5db5f
Show file tree
Hide file tree
Showing 14 changed files with 2,423 additions and 4,304 deletions.
2 changes: 1 addition & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require("esbuild")
outExtension: {
".js": ".mjs",
},
external: ["i18next", "country-code-to-flag-emoji"],
external: ["i18next", "locale-emoji"],
minify: false,
format: "esm",
platform: "node",
Expand Down
10 changes: 9 additions & 1 deletion example/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ export default defineConfig({
integrations: true,
},
integrations: [
sitemap(),
sitemap({
i18n: {
defaultLocale: "en", // All urls that don't contain `es` or `fr` after `https://stargazers.club/` will be treated as default locale, i.e. `en`
locales: {
en: "en", // The `defaultLocale` value must present in `locales` keys
fr: "fr",
},
},
}),
tailwind(),
astroI18next({
baseLocale: "en",
Expand Down
2,865 changes: 864 additions & 2,001 deletions example/package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"preview": "astro preview"
},
"devDependencies": {
"@astrojs/sitemap": "^0.1.2",
"@astrojs/tailwind": "^0.2.1",
"astro": "^1.0.0-beta.47",
"astro-seo": "^0.5.0"
"@astrojs/sitemap": "^0.3.0",
"@astrojs/tailwind": "^0.2.5",
"astro": "1.0.0-rc.7",
"astro-seo": "^0.5.1"
},
"dependencies": {
"i18next-fs-backend": "^1.1.4"
"i18next-fs-backend": "^1.1.5"
}
}
2 changes: 1 addition & 1 deletion example/src/components/atoms/Button.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ 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>
><slot />
</a>
2 changes: 1 addition & 1 deletion example/src/components/atoms/Link.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ const { ...attributes } = Astro.props;
<a
class="underline hover:no-underline decoration-4 decoration-cyan-500"
{...attributes}
><slot></slot>
><slot />
</a>
12 changes: 5 additions & 7 deletions example/src/components/molecules/Navigation.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import i18next, { t } from "i18next";
import { localizePath } from "astro-i18next";
const { ...attributes } = Astro.props;
const { pathname } = Astro.canonicalURL;
const { pathname } = Astro.url;
const navigationItems = {
"/": t("navigation.home"),
Expand All @@ -14,19 +14,17 @@ const navigationItems = {
<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"

"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 "
className += " underline decoration-cyan-500";
} else {
className +=
" opacity-75 hover:opacity-100 hover:underline decoration-gray-300"
" opacity-75 hover:opacity-100 hover:underline decoration-gray-300";
}

return (
<a class={className} href={localizePath(key, i18next.language)}>
{navigationItems[key]}
</a>
)
);
})}
</nav>
7 changes: 2 additions & 5 deletions example/src/components/organisms/HeadSEO.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { SEO } from "astro-seo";
import { t } from "i18next";
const { href: canonicalUrl } = Astro.canonicalURL;
const { href: canonicalUrl } = Astro.url;
---

<link rel="icon" type="image/x-icon" href="/favicon.ico" />
Expand All @@ -26,8 +26,5 @@ const { href: canonicalUrl } = Astro.canonicalURL;
type: "image/jpeg",
},
}}
twitter={{
card: "summary_large_image",
creator: "@yassinedoghri",
}}
twitter={{ card: "summary_large_image", creator: "@yassinedoghri" }}
/>
2 changes: 1 addition & 1 deletion example/src/components/templates/BaseTemplate.astro
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Button from "atoms:Button";
/>
</div>
<Navigation />
<slot></slot>
<slot />
<Button
class="mt-8"
href="https://github.com/yassinedoghri/astro-i18next#readme"
Expand Down
Loading

0 comments on commit 3a5db5f

Please sign in to comment.