mirror of
https://codeberg.org/HPCesia/AstralHalo.git
synced 2025-04-08 17:34:27 +08:00
feat: favicon
This commit is contained in:
parent
0a04480abc
commit
2210d608e4
BIN
public/favicon/favicon-128x128.png
Normal file
BIN
public/favicon/favicon-128x128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
public/favicon/favicon-180x180.png
Normal file
BIN
public/favicon/favicon-180x180.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
public/favicon/favicon-192x192.png
Normal file
BIN
public/favicon/favicon-192x192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
BIN
public/favicon/favicon-32x32.png
Normal file
BIN
public/favicon/favicon-32x32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
@ -16,7 +16,10 @@ export const siteConfig: SiteConfig = {
|
||||
title: 'Astral Halo',
|
||||
subtitle: '',
|
||||
lang: 'en', // "en" | "zh_CN" | "zh_TW"
|
||||
favicon: [''],
|
||||
favicon: [
|
||||
// Leave this array empty to use the default favicon.
|
||||
// 留空数组以使用默认的 favicon。
|
||||
],
|
||||
postsPerPage: 10,
|
||||
};
|
||||
|
||||
|
20
src/constants/icon.ts
Normal file
20
src/constants/icon.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import type { Favicon } from '@/types/config';
|
||||
|
||||
export const defaultFavicons: Favicon[] = [
|
||||
{
|
||||
src: '/favicon/favicon-32x32.png',
|
||||
sizes: '32x32',
|
||||
},
|
||||
{
|
||||
src: '/favicon/favicon-128x128.png',
|
||||
sizes: '128x128',
|
||||
},
|
||||
{
|
||||
src: '/favicon/favicon-180x180.png',
|
||||
sizes: '180x180',
|
||||
},
|
||||
{
|
||||
src: '/favicon/favicon-192x192.png',
|
||||
sizes: '192x192',
|
||||
},
|
||||
];
|
@ -1,6 +1,8 @@
|
||||
---
|
||||
import { profileConfig, siteConfig } from '@/config';
|
||||
import '@/styles/global.css';
|
||||
import type { Favicon } from '@/types/config';
|
||||
import { defaultFavicons } from '@constants/icon';
|
||||
import { ClientRouter } from 'astro:transitions';
|
||||
|
||||
interface Props {
|
||||
@ -18,6 +20,9 @@ else
|
||||
|
||||
if (!lang) lang = `${siteConfig.lang}`;
|
||||
const siteLang = lang.replace('_', '-');
|
||||
|
||||
const favicons: Favicon[] =
|
||||
siteConfig.favicon.length > 0 ? siteConfig.favicon : defaultFavicons;
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
@ -45,6 +50,20 @@ const siteLang = lang.replace('_', '-');
|
||||
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
|
||||
{
|
||||
favicons.map((favicon) => (
|
||||
<link
|
||||
rel="icon"
|
||||
href={
|
||||
favicon.src.startsWith('/')
|
||||
? ['', import.meta.env.BASE_URL, favicon.src].join('/').replace(/\/+/g, '/')
|
||||
: favicon.src
|
||||
}
|
||||
sizes={favicon.sizes}
|
||||
/>
|
||||
))
|
||||
}
|
||||
|
||||
<slot name="head" />
|
||||
</head>
|
||||
<body class="bg-base-100 text-base-content flex min-h-screen flex-col">
|
||||
|
@ -1,5 +1,20 @@
|
||||
import type I18nKey from '@i18n/I18nKey';
|
||||
|
||||
export type Favicon = {
|
||||
/**
|
||||
* The URL of the favicon.
|
||||
*
|
||||
* favicon 的 URL。
|
||||
*/
|
||||
src: string;
|
||||
/**
|
||||
* The sizes of the favicon.
|
||||
*
|
||||
* favicon 的尺寸。
|
||||
*/
|
||||
sizes?: `${string}x${string}`;
|
||||
};
|
||||
|
||||
export type ButtonSubConfig<T extends string> = T extends 'text'
|
||||
? {
|
||||
/**
|
||||
@ -94,7 +109,7 @@ export type SiteConfig = {
|
||||
*
|
||||
* 站点的 favicon。
|
||||
*/
|
||||
favicon: string[];
|
||||
favicon: Favicon[];
|
||||
/**
|
||||
* The number of posts displayed per page.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user