feat: add i18n support

This commit is contained in:
DuroCodes
2024-05-14 20:53:47 -04:00
parent 441af2e4aa
commit f43a51c7b1
6 changed files with 93 additions and 1 deletions

32
.github/workflows/lunaria.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: Lunaria
on:
pull_request_target:
types: [opened, synchronize]
branches: [main]
permissions:
contents: read
pull-requests: write
jobs:
lunaria-overview:
name: Generate Lunaria Overview
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install Dependencies
run: bun install
- name: Generate Lunaria Overview
uses: yanthomasdev/lunaria-action@main

View File

@@ -3,12 +3,26 @@ import starlight from '@astrojs/starlight';
import starlightBlog from 'starlight-blog';
import tailwind from "@astrojs/tailwind";
import starlightTypeDoc, { typeDocSidebarGroup } from 'starlight-typedoc';
import lunaria from '@lunariajs/starlight';
import { GITHUB_URL, DISCORD_URL } from './src/utils/consts';
export default defineConfig({
integrations: [starlight({
title: 'sern',
lastUpdated: true,
defaultLocale: 'root',
locales: {
root: {
label: 'English',
lang: 'en',
},
es: {
label: 'Español',
},
tr: {
label: 'Türkçe',
},
},
social: {
github: GITHUB_URL,
discord: DISCORD_URL,
@@ -21,6 +35,7 @@ export default defineConfig({
SiteTitle: '~/overrides/SiteTitle.astro',
ThemeSelect: '~/overrides/ThemeSelect.astro',
Sidebar: '~/overrides/Sidebar.astro',
FallbackContentNotice: '~/overrides/FallbackContentNotice.astro',
},
logo: {
src: '~/assets/logo/navbar-icon.png',
@@ -108,6 +123,7 @@ export default defineConfig({
},
sidebar: { collapsed: true },
}),
lunaria(),
],
}), tailwind()]
});

BIN
bun.lockb

Binary file not shown.

31
lunaria.config.json Normal file
View File

@@ -0,0 +1,31 @@
{
"$schema": "./node_modules/@lunariajs/core/config.schema.json",
"repository": {
"name": "durocodes/sern-website"
},
"defaultLocale": {
"label": "English",
"lang": "en"
},
"locales": [
{
"label": "English",
"lang": "en"
},
{
"label": "Español",
"lang": "es"
},
{
"label": "Türkçe",
"lang": "tr"
}
],
"files": [
{
"location": "src/content/docs/**/*.{md,mdx}",
"pattern": "@lang/@path",
"type": "universal"
}
]
}

View File

@@ -8,7 +8,9 @@
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro",
"postinstall": "bun run setup.mjs"
"postinstall": "bun run setup.mjs",
"lunaria:build": "lunaria build",
"lunaria:preview": "lunaria preview"
},
"dependencies": {
"@astrojs/check": "^0.5.10",
@@ -16,6 +18,8 @@
"@astrojs/starlight-tailwind": "^2.0.2",
"@astropub/md": "^0.4.0",
"@expressive-code/plugin-line-numbers": "^0.35.3",
"@lunariajs/core": "^0.0.32",
"@lunariajs/starlight": "^0.0.6",
"astro": "^4.3.5",
"sharp": "^0.32.5",
"starlight-blog": "^0.7.1",

View File

@@ -0,0 +1,9 @@
---
import StarlightFallbackContentNotice from "@astrojs/starlight/components/FallbackContentNotice.astro";
import type { Props } from "@astrojs/starlight/props";
const { slug } = Astro.props;
const isApi = slug.includes("/api/");
---
{!isApi && <StarlightFallbackContentNotice {...Astro.props} />}