File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ import ImageWrapper from " ./ImageWrapper.astro" ;
3+ import { siteConfig } from " ../../config" ;
4+
5+ interface Props {
6+ id? : string ;
7+ class? : string ;
8+ alt? : string ;
9+ }
10+
11+ const { id, alt } = Astro .props ;
12+ const className = Astro .props .class ;
13+ const bannerConfig = siteConfig .banner ;
14+ ---
15+
16+ <div id ={ id } class:list ={ [className , ' relative overflow-hidden' ]} >
17+ <ImageWrapper
18+ src ={ bannerConfig .src }
19+ position ={ bannerConfig .position }
20+ alt ={ alt || " Banner image of the blog" }
21+ class =" w-full h-full"
22+ />
23+
24+ { bannerConfig .text ?.enable && (
25+ <div class = " absolute inset-0 flex items-center justify-center z-20" >
26+ <div class = " text-center text-white px-6 py-4" >
27+ { bannerConfig .text .title && (
28+ <h1 class = " text-3xl md:text-5xl font-bold mb-2 drop-shadow-lg" >
29+ { bannerConfig .text .title }
30+ </h1 >
31+ )}
32+ { bannerConfig .text .subtitle && (
33+ <p class = " text-lg md:text-xl opacity-90 drop-shadow-md" >
34+ { bannerConfig .text .subtitle }
35+ </p >
36+ )}
37+ </div >
38+ </div >
39+ )}
40+ </div >
Original file line number Diff line number Diff line change 1+ import { AUTO_MODE , DARK_MODE , LIGHT_MODE } from "./constants/constants" ;
12import type {
23 CommentConfig ,
34 ExpressiveCodeConfig ,
@@ -7,7 +8,6 @@ import type {
78 SiteConfig ,
89} from "./types/config" ;
910import { LinkPreset } from "./types/config" ;
10- import { AUTO_MODE , DARK_MODE , LIGHT_MODE } from "./constants/constants" ;
1111
1212export const siteConfig : SiteConfig = {
1313 title : "fishcpy的小破站" ,
@@ -28,6 +28,11 @@ export const siteConfig: SiteConfig = {
2828 text : "" , // 要显示的版权文本
2929 url : "" , // (可选) 原作品或艺术家页面的URL链接
3030 } ,
31+ text : {
32+ enable : true , // 是否在banner中显示文字
33+ title : "非淡泊无以明志,非宁静无以致远" , // banner主标题
34+ subtitle : "Welcome to my blog" , // banner副标题
35+ } ,
3136 } ,
3237 toc : {
3338 enable : true , // 在文章右侧显示目录
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ export const LIGHT_MODE = "light",
66export const DEFAULT_THEME = AUTO_MODE ;
77
88// Banner height unit: vh
9- export const BANNER_HEIGHT = 35 ;
10- export const BANNER_HEIGHT_EXTEND = 30 ;
9+ export const BANNER_HEIGHT = 45 ;
10+ export const BANNER_HEIGHT_EXTEND = 35 ;
1111export const BANNER_HEIGHT_HOME = BANNER_HEIGHT + BANNER_HEIGHT_EXTEND ;
1212
1313// The height the main panel overlaps the banner, unit: rem
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import Twikoo from "@components/comment/Twikoo.astro";
77import type { MarkdownHeading } from " astro" ;
88import { Icon } from " astro-icon/components" ;
99import ImageWrapper from " ../components/misc/ImageWrapper.astro" ;
10+ import BannerWrapper from " ../components/misc/BannerWrapper.astro" ;
1011import TOC from " ../components/widget/TOC.astro" ;
1112import { siteConfig } from " ../config" ;
1213import {
@@ -38,7 +39,7 @@ const hasBannerCredit =
3839const hasBannerLink = !! siteConfig .banner .credit .url ;
3940
4041const mainPanelTop = siteConfig .banner .enable
41- ? ` calc(${BANNER_HEIGHT }vh - ${MAIN_PANEL_OVERLAPS_BANNER_HEIGHT }rem) `
42+ ? ` calc(${BANNER_HEIGHT }vh - ${MAIN_PANEL_OVERLAPS_BANNER_HEIGHT }rem + 6rem ) `
4243 : " 5.5rem" ;
4344---
4445
@@ -54,10 +55,9 @@ const mainPanelTop = siteConfig.banner.enable
5455
5556<!-- Banner -->
5657{ siteConfig .banner .enable && <div id = " banner-wrapper" class = { ` absolute z-10 w-full transition duration-700 overflow-hidden ` } style = { ` top: calc(-1 * var(--banner-height-extend)) ` } >
57- <ImageWrapper id = " banner" alt = " Banner image of the blog" class :list = { [" object-cover h-full transition duration-700 opacity-0 scale-105" ]}
58- src = { siteConfig .banner .src } position = { siteConfig .banner .position }
58+ <BannerWrapper id = " banner" alt = " Banner image of the blog" class :list = { [" object-cover h-full transition duration-700 opacity-0 scale-105" ]}
5959 >
60- </ImageWrapper >
60+ </BannerWrapper >
6161</div >}
6262
6363<!-- Main content -->
Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ export type SiteConfig = {
2020 text : string ;
2121 url ?: string ;
2222 } ;
23+ text ?: {
24+ enable : boolean ;
25+ title ?: string ;
26+ subtitle ?: string ;
27+ } ;
2328 } ;
2429 toc : {
2530 enable : boolean ;
You can’t perform that action at this time.
0 commit comments