mirror of
https://github.com/101island/lolisland.us.git
synced 2026-03-01 03:49:42 +08:00
feat: using unocss to add icons
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
import cloudflare from "@astrojs/cloudflare";
|
import cloudflare from "@astrojs/cloudflare";
|
||||||
import react from "@astrojs/react";
|
import react from "@astrojs/react";
|
||||||
import { defineConfig } from "astro/config";
|
import { defineConfig } from "astro/config";
|
||||||
|
import UnoCSS from "unocss/astro";
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
adapter: cloudflare(),
|
adapter: cloudflare(),
|
||||||
integrations: [react()],
|
integrations: [react(), UnoCSS()],
|
||||||
i18n: {
|
i18n: {
|
||||||
defaultLocale: "zh-cn",
|
defaultLocale: "zh-cn",
|
||||||
locales: ["en", "zh-cn", "zh-hk", "ja"],
|
locales: ["en", "zh-cn", "zh-hk", "ja"],
|
||||||
|
|||||||
@@ -19,11 +19,13 @@
|
|||||||
"@types/react": "^19.2.7",
|
"@types/react": "^19.2.7",
|
||||||
"@types/react-dom": "^19.2.3",
|
"@types/react-dom": "^19.2.3",
|
||||||
"astro": "^5.0.0",
|
"astro": "^5.0.0",
|
||||||
"flag-icons": "^7.5.0",
|
|
||||||
"react": "^19.2.3",
|
"react": "^19.2.3",
|
||||||
"react-dom": "^19.2.3"
|
"react-dom": "^19.2.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "2.3.8"
|
"@biomejs/biome": "2.3.8",
|
||||||
|
"@iconify-json/flag": "^1.2.10",
|
||||||
|
"@unocss/preset-icons": "^66.5.10",
|
||||||
|
"unocss": "^66.5.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
---
|
---
|
||||||
import { languages } from "../i18n/ui";
|
import { languages } from "../i18n/ui";
|
||||||
import { getLangFromUrl, getTranslatedPath } from "../i18n/utils";
|
import { getLangFromUrl, getTranslatedPath } from "../i18n/utils";
|
||||||
import "flag-icons/css/flag-icons.min.css";
|
|
||||||
|
|
||||||
const lang = getLangFromUrl(Astro.url);
|
const lang = getLangFromUrl(Astro.url);
|
||||||
const translatePath = getTranslatedPath(lang);
|
const translatePath = getTranslatedPath(lang);
|
||||||
|
|
||||||
// https://flagicons.lipis.dev/
|
// https://flagicons.lipis.dev/
|
||||||
const flags: Record<string, string> = {
|
const flags: Record<string, string> = {
|
||||||
en: "fi fi-us",
|
en: "i-flag:us-4x3",
|
||||||
"zh-cn": "fi fi-cn",
|
"zh-cn": "i-flag:cn-4x3",
|
||||||
"zh-hk": "fi fi-hk",
|
"zh-hk": "i-flag:hk-4x3",
|
||||||
ja: "fi fi-jp",
|
ja: "i-flag:jp-4x3",
|
||||||
};
|
};
|
||||||
|
|
||||||
const currentFlagClass = flags[lang];
|
const currentFlagClass = flags[lang];
|
||||||
|
|||||||
6
uno.config.ts
Normal file
6
uno.config.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { defineConfig } from "unocss";
|
||||||
|
import presetIcons from "@unocss/preset-icons";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
presets: [presetIcons()],
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user