-
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 astro integration --> initialize i18next upon astro:config:…
…setup - update src structure to split integration from components - update package.json to export subpath for components - bundle project using esbuild - add typescript type declarations to package - add baseLanguage property to LanguageSelector + update readme docs
- Loading branch information
1 parent
8882712
commit 78ec744
Showing
10 changed files
with
69 additions
and
16 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
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,23 @@ | ||
#!/usr/bin/env node | ||
|
||
require("esbuild") | ||
.build({ | ||
bundle: true, | ||
entryPoints: ["src/index.mts", "src/utils.ts", "src/components/index.mts"], | ||
outdir: "dist", | ||
outExtension: { | ||
".js": ".mjs", | ||
}, | ||
external: ["i18next", "country-code-to-flag-emoji"], | ||
minify: false, | ||
format: "esm", | ||
platform: "node", | ||
target: "node14", | ||
sourcemap: "inline", | ||
sourcesContent: false, | ||
loader: { | ||
".astro": "file", | ||
}, | ||
assetNames: "[dir]/[name]", | ||
}) | ||
.catch(() => process.exit(1)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,2 @@ | ||
export { default as Trans } from "./Trans.astro"; | ||
export { default as LanguageSelector } from "./LanguageSelector.astro"; |
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,2 +1,20 @@ | ||
export { default as Trans } from "./Trans.astro"; | ||
export { default as LanguageSelector } from "./LanguageSelector.astro"; | ||
import { AstroIntegration } from "astro"; | ||
import { InitOptions } from "i18next"; | ||
|
||
export default (options: InitOptions): AstroIntegration => { | ||
return { | ||
name: "astro-i18next", | ||
hooks: { | ||
"astro:config:setup": async ({ config, injectScript }) => { | ||
// TODO: include other options? Abstract translation files loading? | ||
|
||
// init i18next | ||
injectScript( | ||
"page-ssr", | ||
`import i18next from "i18next"; | ||
i18next.init(${JSON.stringify(options)});` | ||
); | ||
}, | ||
}, | ||
}; | ||
}; |
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,9 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"skipLibCheck": true, | ||
"moduleResolution": "node", | ||
"baseUrl": "src", | ||
"lib": ["ES2021"] | ||
}, | ||
"include": ["src/**/*.ts", "src/**/*.mts", "src/**/*.astro", "src/index.mjs"], | ||
"exclude": [] | ||
"include": ["src/**/*"], | ||
"exclude": ["src/**/*.test.ts"] | ||
} |