添加友情链接功能
This commit is contained in:
BIN
public/sotr.jpg
Normal file
BIN
public/sotr.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 153 KiB |
@@ -17,5 +17,7 @@ const currentYear = new Date().getFullYear();
|
|||||||
Powered by
|
Powered by
|
||||||
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href="https://astro.build">Astro</a> &
|
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href="https://astro.build">Astro</a> &
|
||||||
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href="https://github.com/saicaca/fuwari">Fuwari</a>
|
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href="https://github.com/saicaca/fuwari">Fuwari</a>
|
||||||
|
<span> / </span>
|
||||||
|
<a class="transition link text-[var(--primary)] font-medium" target="_blank" href="https://kira.moe">Sotr's Blog</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
27
src/components/widget/FriendShip.astro
Normal file
27
src/components/widget/FriendShip.astro
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
import { Image } from "astro:assets";
|
||||||
|
import I18nKey from "../../i18n/i18nKey";
|
||||||
|
import { i18n } from "../../i18n/translation";
|
||||||
|
import WidgetLayout from "./WidgetLayout.astro";
|
||||||
|
import ButtonTag from "@components/control/ButtonTag.astro";
|
||||||
|
import type { SiteConfig } from "../../types/config";
|
||||||
|
import { siteConfig } from "@/config";
|
||||||
|
|
||||||
|
const COLLAPSED_HEIGHT = "7.5rem";
|
||||||
|
const className = Astro.props.class;
|
||||||
|
const style = Astro.props.style;
|
||||||
|
|
||||||
|
const FRIENDS = siteConfig.friendsConfig?.items || [];
|
||||||
|
const FRIENDS_ENABLED = siteConfig.friendsConfig?.enable || false;
|
||||||
|
---
|
||||||
|
{FRIENDS_ENABLED && (
|
||||||
|
<WidgetLayout name={i18n(I18nKey.friendship)} id="friends" collapsedHeight={COLLAPSED_HEIGHT} class={className} style={style}>
|
||||||
|
<div class="flex gap-2 flex-wrap">
|
||||||
|
{FRIENDS.map((friend) => (
|
||||||
|
<ButtonTag href={friend.url} label={friend.name}>
|
||||||
|
<Image src={friend.imgSrc || "/default-friend-icon.png"} alt={friend.imgAlt || ""} width={20} height={20} class="rounded-full mr-2" />{friend.name}
|
||||||
|
</ButtonTag>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</WidgetLayout>
|
||||||
|
)}
|
||||||
@@ -3,6 +3,8 @@ import type { MarkdownHeading } from "astro";
|
|||||||
import Categories from "./Categories.astro";
|
import Categories from "./Categories.astro";
|
||||||
import Profile from "./Profile.astro";
|
import Profile from "./Profile.astro";
|
||||||
import Tag from "./Tags.astro";
|
import Tag from "./Tags.astro";
|
||||||
|
import FriendShip from "./FriendShip.astro";
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
class?: string;
|
class?: string;
|
||||||
@@ -18,5 +20,6 @@ const className = Astro.props.class;
|
|||||||
<div id="sidebar-sticky" class="transition-all duration-700 flex flex-col w-full gap-4 top-4 sticky top-4">
|
<div id="sidebar-sticky" class="transition-all duration-700 flex flex-col w-full gap-4 top-4 sticky top-4">
|
||||||
<Categories class="onload-animation" style="animation-delay: 150ms"></Categories>
|
<Categories class="onload-animation" style="animation-delay: 150ms"></Categories>
|
||||||
<Tag class="onload-animation" style="animation-delay: 200ms"></Tag>
|
<Tag class="onload-animation" style="animation-delay: 200ms"></Tag>
|
||||||
|
<FriendShip class="onload-animation" style="animation-delay: 250ms"></FriendShip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -29,6 +29,15 @@ export const siteConfig: SiteConfig = {
|
|||||||
enable: true, // Display the table of contents on the right side of the post
|
enable: true, // Display the table of contents on the right side of the post
|
||||||
depth: 3, // Maximum heading depth to show in the table, from 1 to 3
|
depth: 3, // Maximum heading depth to show in the table, from 1 to 3
|
||||||
},
|
},
|
||||||
|
friendsConfig: {
|
||||||
|
enable: true,
|
||||||
|
items: [{
|
||||||
|
name: "Sotr's Blog",
|
||||||
|
url: "https://kira.moe",
|
||||||
|
imgSrc: "/sotr.jpg",
|
||||||
|
imgAlt: "Sotr's Blog",
|
||||||
|
},],
|
||||||
|
},
|
||||||
favicon: [
|
favicon: [
|
||||||
// Leave this array empty to use the default favicon
|
// Leave this array empty to use the default favicon
|
||||||
// {
|
// {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ enum I18nKey {
|
|||||||
search = "search",
|
search = "search",
|
||||||
download = "download",
|
download = "download",
|
||||||
|
|
||||||
|
friendship = "friendship",
|
||||||
tags = "tags",
|
tags = "tags",
|
||||||
categories = "categories",
|
categories = "categories",
|
||||||
recentPosts = "recentPosts",
|
recentPosts = "recentPosts",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export const zh_CN: Translation = {
|
|||||||
[Key.search]: "搜索",
|
[Key.search]: "搜索",
|
||||||
[Key.download]: "下载",
|
[Key.download]: "下载",
|
||||||
|
|
||||||
|
[Key.friendship]: "友情链接",
|
||||||
[Key.tags]: "标签",
|
[Key.tags]: "标签",
|
||||||
[Key.categories]: "分类",
|
[Key.categories]: "分类",
|
||||||
[Key.recentPosts]: "最新文章",
|
[Key.recentPosts]: "最新文章",
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export type SiteConfig = {
|
|||||||
enable: boolean;
|
enable: boolean;
|
||||||
depth: 1 | 2 | 3;
|
depth: 1 | 2 | 3;
|
||||||
};
|
};
|
||||||
|
friendsConfig?: FriendsConfig;
|
||||||
favicon: Favicon[];
|
favicon: Favicon[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,6 +44,18 @@ export type Favicon = {
|
|||||||
sizes?: string;
|
sizes?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type FriendItem = {
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
imgSrc?: string;
|
||||||
|
imgAlt?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FriendsConfig = {
|
||||||
|
enable: boolean;
|
||||||
|
items: FriendItem[];
|
||||||
|
};
|
||||||
|
|
||||||
export enum LinkPreset {
|
export enum LinkPreset {
|
||||||
Home = 0,
|
Home = 0,
|
||||||
Archive = 1,
|
Archive = 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user