Skip to content

Commit

Permalink
i18n 対応の実験 (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
so-asano authored and nkte8 committed Apr 13, 2024
1 parent f42b9de commit 49c1ec9
Show file tree
Hide file tree
Showing 9 changed files with 880 additions and 24 deletions.
1 change: 1 addition & 0 deletions astro/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module.exports = {
"tailwind.config.mjs",
"jest.config.cjs",
"astro.config.mjs",
"astro-i18next.config.ts",
],
overrides: [
{
Expand Down
3 changes: 3 additions & 0 deletions astro/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ pnpm-debug.log*

# macOS-specific files
.DS_Store

# i18n
astro_tmp_pages_*
8 changes: 8 additions & 0 deletions astro/astro-i18next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { AstroI18nextConfig } from "@/../../node_modules/astro-i18next";

const config: AstroI18nextConfig = {
defaultLocale: "ja",
locales: ["ja", "en"],
};

export default config;
74 changes: 55 additions & 19 deletions astro/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,59 @@
import { defineConfig } from 'astro/config';
import react from "@astrojs/react";
import tailwind from "@astrojs/tailwind";
import cloudflare from "@astrojs/cloudflare";
import partytown from '@astrojs/partytown';
import { defineConfig } from "astro/config"
import react from "@astrojs/react"
import tailwind from "@astrojs/tailwind"
import cloudflare from "@astrojs/cloudflare"
import partytown from "@astrojs/partytown"
import astroI18next from "astro-i18next"
import { i18n, filterSitemapByDefaultLocale } from "astro-i18n-aut/integration"
import sitemap from "@astrojs/sitemap"

const defaultLocale = "ja"
const locales = {
ja: "ja", // the `defaultLocale` value must present in `locales` keys
en: "en",
}

// https://astro.build/config
/** @type {import('tailwindcss').Config} */
export default defineConfig({
base: "/",
site: "https://skyshare.uk/",
server: {
port: 4321,
host: true
},
integrations: [
react(),
tailwind(),
partytown()
],
output: "hybrid",
adapter: cloudflare(),
});
base: "/",
site: "https://skyshare.uk/",
server: {
port: 4321,
host: true,
},
integrations: [
react(),
tailwind(),
partytown(),
astroI18next(),
i18n({
locales,
defaultLocale,
}),
sitemap({
i18n: {
locales,
defaultLocale,
},
filter: filterSitemapByDefaultLocale({ defaultLocale }),
}),
],
output: "hybrid",
adapter: cloudflare(),
// 不要?
// i18n: {
// defaultLocale: "ja",
// locales: ["ja", "en"],
// fallback: ["ja", "en"],
// },
trailingSlash: "always",
build: {
format: "directory",
},
routing: {
prefixDefaultLocale: true,
},
})

import { defineConfig } from "astro/config"
Loading

0 comments on commit 49c1ec9

Please sign in to comment.