Files
zhaoguiyang.site/src/types/index.ts
joyzhao deb80c0df7 feat(blog): add tagId and categoryId for multilingual routing support
- Add tagId and categoryId fields to blog post frontmatter and interfaces
- Update blog list, category, and tag pages to use IDs for routing
- Implement fallback to regular tags/categories when IDs are not available
- Improve tag and category links with hover effects and proper encoding
- Update post meta component to support multilingual routing
2025-06-19 14:08:47 +08:00

163 lines
2.8 KiB
TypeScript

/**
* 集中管理项目中的类型定义
* 这个文件包含了项目中常用的接口和类型定义,减少代码冗余和提高可维护性
*/
import { languages } from '@/i18n/ui';
/**
* 语言类型定义
*/
export type Lang = keyof typeof languages;
/**
* 国际化文本键类型
*/
export type UiKeys = string;
/**
* 多语言文本类型
*/
export type LocalizedText = {
[K in Lang]: string;
};
/**
* 作者信息接口
*/
export interface Author {
name: string;
bio?: string;
avatar?: string;
website?: string;
twitter?: string;
github?: string;
linkedin?: string;
}
/**
* 博客文章接口
*/
export interface BlogPost {
title: string;
description: string;
image: string;
slug: string;
tags: string[];
tagId?: string[];
category?: string[];
categoryId?: string[];
date: string;
readTime: string;
url?: string;
}
/**
* 博客文章前置元数据接口
*/
export interface FrontmatterProps {
title: string;
description?: string;
publishDate?: string;
date?: string; // Alternative field name for publish date
author?: string;
tags?: string[];
tagId?: string[]; // 标签唯一标识符,用于多语言环境下的标签路由
category?: string | string[];
categoryId?: string[] | string; // 分类唯一标识符,用于多语言环境下的分类路由
readingTime?: number;
readTime?: string; // Alternative field name for reading time
}
/**
* 技能项接口
*/
export interface SkillItem {
name: string;
icon: string; // skillicons icon name
}
/**
* 个人信息接口
*/
export interface PersonalInfo {
name: string;
location: string;
avatar: string;
email: string;
github: string;
linkedin: string;
website: string;
twitter: string;
position: LocalizedText;
description: LocalizedText;
about: {
[K in Lang]: string[];
};
stats: {
repositories: number;
commits: string;
contributions: number;
};
skills: {
frontend: string[];
backend: string[];
database: string[];
devops: string[];
mobile: string[];
};
terminal: {
username: string;
};
}
/**
* 组件 Props 接口
*/
/**
* 作者卡片组件 Props
*/
export interface AuthorCardProps {
lang: Lang;
author?: Author;
}
/**
* 分享按钮组件 Props
*/
export interface ShareButtonsProps {
lang: Lang;
title: string;
url?: string;
}
/**
* 页脚组件 Props
*/
export interface FooterProps {
lang?: Lang;
}
/**
* 玻璃标题组件 Props
*/
export interface GlassHeaderProps {
lang: Lang;
}
/**
* 博客列表组件 Props
*/
export interface BlogListProps {
posts: BlogPost[];
lang: Lang;
baseUrl?: string; // Base URL for blog posts, defaults to '/blog/posts/'
}
/**
* 语言切换器组件 Props
*/
export interface LanguageSwitcherProps {
lang: Lang;
}