ts
import type { DefaultTheme } from 'valaxy'
import type { Footer } from './footer'
import type { Hero } from './hero'
import type { SakuraLayoutOptions } from './layout'
import type { LinkItem } from './link'
import type { NavbarOptions, NavItem } from './navbar'
import type { Pagination } from './pagination'
import type { PinnedPost } from './pinned'
import type { PostFooter, PostList } from './post'
import type { SidebarItem, SidebarOptions } from './sidebar'
import type { UserUI } from './ui'
export interface ThemeConfig extends DefaultTheme.Config {
ui: UserUI
/**
* @zh 布局配置
* @en Layout configuration
*/
layout: Record<string, SakuraLayoutOptions>
/**
* @zh 页脚配置
* @en Footer configuration
*/
footer: Footer
/**
* @zh 置顶文章
* @en Pinned articles
*/
pinnedPost?: PinnedPost
/**
* @zh 文章配置
* @en Post configuration
*/
postList?: PostList
postFooter?: PostFooter
/**
* @zh 友情链接
* @en Links
*/
links?: LinkItem[]
/**
* @deprecated Use hero instead
*/
banner: Hero
/**
* @zh 横幅配置
* @en Banner configuration
*/
hero: Hero
/**
* @zh 侧边栏配置
* @en Sidebar configuration
*/
sidebar: NavItem[] | SidebarItem[]
/**
* @zh 侧边栏选项配置
* @en Sidebar options configuration
*/
sidebarOptions: SidebarOptions
/**
* @zh 是否显示站点图标
* @en Whether to display the site favicon
* @default true
* @deprecated Use navbarOptions.favicon instead
*/
favicon: boolean
/**
* @zh 导航栏
* @en Navbar
*/
navbar: NavItem[]
/**
* @zh 导航栏选项配置
* @en Navbar options configuration
*/
navbarOptions: NavbarOptions
/**
* @zh 大纲标题
* @en Outline title
*/
outlineTitle?: string
/**
* @zh 分页配置
* @en Pagination configuration
*/
pagination?: Pagination
/**
* @zh 滚动阻尼
* @en Scroll damping
* @default false
*/
scrollDamping: boolean
/**
* @zh 滚动动画
* @en Scroll animation
* @default true
*/
scrollAnimation: boolean
/**
* @default false
*/
scrollIndicator: boolean
/**
* @default true
*/
scrollLock: boolean
/**
* @zh 是否显示滚动到顶部组件,默认为按钮样式
* @en Whether to display the scroll-to-top component. The default is a button style.
* @default true
*/
scrollToTop: boolean | 'cord'
/**
* @zh 404图片
* @en Image for the 404
*/
notFoundImage?: string
/**
* @zh 公告
* @en Notice
*/
notice?: {
/**
* @zh 公告信息
* @en Notice message
*/
message: string
}
tags?: {
/**
* @zh 是否开启彩色标签
* @en Whether to enable rainbow tags
* @default false
*/
rainbow?: boolean | string[]
}
}
export type ThemeUserConfig = {
[K in keyof ThemeConfig]?: Partial<ThemeConfig[K]>
}
/**
* @deprecated Use ThemeUserConfig instead
*/
export type UserThemeConfig = ThemeUserConfig示例
在 Valaxy 中,ThemeConfig 是 export default defineValaxyConfig<ThemeConfig> 中的 themeConfig 部分,允许用户对主题进行个性化配置以下是 valaxy-theme-sakura 主题 demo 的配置示例:
ts
import type { ThemeUserConfig } from 'valaxy-theme-sakura'
import { defineValaxyConfig } from 'valaxy'
import { addonBangumi } from 'valaxy-addon-bangumi'
import { addonHitokoto } from 'valaxy-addon-hitokoto'
import { addonWaline } from 'valaxy-addon-waline'
export default defineValaxyConfig<ThemeUserConfig>({
theme: 'sakura',
devtools: true,
themeConfig: {
ui: {
primary: '#fe9500',
toggleDarkButton: {
lightIcon: 'i-line-md-moon-alt-to-sunny-outline-loop-transition',
darkIcon: 'i-line-md-sunny-outline-to-moon-loop-transition',
},
pinnedPost: {
icon: 'i-fa-anchor',
},
postList: {
icon: 'i-fa-envira',
},
},
hero: {
title: 'HI, SAKURA!',
motto: 'You got to put the past behind you before you can move on.',
urls: [
'https://valaxy-theme-sakura.s3.bitiful.net/wallpaper/yae-miko-4k30.mp4',
'https://www.youtube.com/watch?v=OWDcn7hl16A&list=RDmu-semky9Ls&index=2',
'https://valaxy-theme-sakura.s3.bitiful.net/PV/563098369-1-208.mp4',
'https://valaxy-theme-sakura.s3.bitiful.net/theming-demos/mashiro/The Pet Girl of Sakurasou.mp4',
'https://valaxy-theme-sakura.s3.bitiful.net/PV/Original PV Little love song MONGOL 800 cover by Amatsuki.mp4',
'https://www.youtube.com/watch?v=aqz-KE-bpKQ',
],
style: 'dim',
fixedImg: true,
typewriter: true,
enableHitokoto: true,
// waveTheme: 'ripple',
},
notice: {
message: '该项目是开源的!主题开源地址请见: <a href="https://github.com/WRXinYue/valaxy-theme-sakura">https://github.com/WRXinYue/valaxy-theme-sakura</a>',
},
pinnedPost: {
text: 'START:DASH!!',
entries: [
{
title: 'Hello, Valaxy!',
desc: 'Valaxy 介绍',
link: '/posts/hello-valaxy',
},
{
title: 'Docs',
desc: '主题文档',
link: '/posts/guide/getting-started/installation',
img: 'https://valaxy-theme-sakura.s3.bitiful.net/wallpaper-2025%2Fwallhaven-yxoejx.jpg',
},
{
title: 'Classic Sakura',
desc: '经典版 Sakura',
link: 'https://sakura-legacy.wrxinyue.org/',
img: 'https://valaxy-theme-sakura.s3.bitiful.net/demo%2F2025-01-05%20222200.png',
},
{
title: 'Valaxy Docs',
desc: 'Valaxy 文档',
link: 'https://valaxy.site',
img: 'https://valaxy-theme-sakura.s3.bitiful.net/wallpaper-2025%2Fwallhaven-zyxq6j.jpg',
},
],
},
pagination: {
animation: true,
infiniteScrollOptions: {
preload: true,
},
},
postList: {
text: 'Discovery',
categoryOrder: ['getting-started'],
isImageReversed: true,
// defaultImage: ['https://www.dmoe.cc/random.php?random', 'https://www.loliapi.com/acg/pc/?random'],
// defaultImage: ['https://www.dmoe.cc/random.php?random', 'https://img.xjh.me/random_img.php?random?type=bg&return=302'],
responsive: {
'2xl': 3,
'xl': 3,
'lg': 2,
'md': 2,
'sm': 1,
},
},
postFooter: {
navigationMerge: true,
},
links: [
{
name: 'GitHub',
url: 'https://github.com/WRXinYue/valaxy-theme-sakura',
avatar: 'https://github.com/WRXinYue.png',
desc: 'Theme Source',
},
{
name: 'Valaxy',
url: 'https://valaxy.site',
avatar: 'https://valaxy.site/favicon.svg',
desc: 'Valaxy Doc',
},
],
navbar: [
{
locale: 'menu.home',
link: '/',
},
{
locale: 'menu.quick_start',
link: '/posts/guide/getting-started/installation',
},
{
locale: 'menu.tags',
link: '/tags/',
},
{
locale: 'menu.archives',
link: '/archives',
},
{
text: '番剧',
// locale: 'menu.anime',
link: '/anime',
},
{
text: '留言板',
link: '/comment',
},
{
text: '友情链接',
link: '/links',
},
{
text: '发行',
link: '/posts/releases',
},
{
text: '关于',
link: '/about',
target: '_blank',
},
],
navbarOptions: {
showMarker: false,
},
sidebarOptions: {
position: 'left',
},
tags: {
rainbow: true,
},
footer: {
since: 2024,
icon: {
img: '/favicon-16x16.ico',
url: 'https://wrxinyue.org',
title: 'WRXinYue',
},
},
// scrollToTop: true,
scrollIndicator: true,
scrollLock: false,
// scrollDamping: true,
},
addons: [
addonWaline({
serverURL: 'https://waline.wrxinyue.org',
pageview: true,
comment: true,
}),
addonBangumi({
api: 'https://yi_xiao_jiu-bangumi.web.val.run',
bilibiliUid: '438788541',
bgmEnabled: false,
}),
// addonBackgrounds({}),
addonHitokoto({
api: 'intl',
}),
],
})这是关于赞助的一些描述
- 本文链接:https://sakura.wrxinyue.org/posts/guide/getting-started/theme-config
- 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 许可协议。