Skip to content

Commit 3c258a3

Browse files
authored
Merge pull request tangly1024#2540 from tangly1024/feat/heo-info-card-config
Heo主题资料卡牌按钮支持配置
2 parents 951440b + 5dbe4ea commit 3c258a3

File tree

2 files changed

+54
-35
lines changed

2 files changed

+54
-35
lines changed

themes/heo/components/InfoCard.js

+46-34
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ArrowRightCircle, GlobeAlt } from '@/components/HeroIcons'
1+
import { ArrowRightCircle } from '@/components/HeroIcons'
22
import LazyImage from '@/components/LazyImage'
33
import { siteConfig } from '@/lib/config'
44
import Link from 'next/link'
@@ -18,6 +18,10 @@ export function InfoCard(props) {
1818
const router = useRouter()
1919
// 在文章详情页特殊处理
2020
const isSlugPage = router.pathname.indexOf('/[prefix]') === 0
21+
const url1 = siteConfig('HEO_INFO_CARD_URL1', null, CONFIG)
22+
const icon1 = siteConfig('HEO_INFO_CARD_ICON1', null, CONFIG)
23+
const url2 = siteConfig('HEO_INFO_CARD_URL2', null, CONFIG)
24+
const icon2 = siteConfig('HEO_INFO_CARD_ICON2', null, CONFIG)
2125
return (
2226
<Card className='bg-[#4f65f0] dark:bg-yellow-600 text-white flex flex-col w-72 overflow-hidden relative'>
2327
{/* 信息卡牌第一行 */}
@@ -45,25 +49,55 @@ export function InfoCard(props) {
4549
<div className='flex justify-between'>
4650
<div className='flex space-x-3 hover:text-black dark:hover:text-white'>
4751
{/* 两个社交按钮 */}
48-
<div className='bg-indigo-400 p-2 rounded-full transition-colors duration-200 dark:bg-yellow-500 dark:hover:bg-black hover:bg-white'>
49-
<Link href='/about'>
50-
<GlobeAlt className={'w-6 h-6'} />
51-
</Link>
52-
</div>
53-
<div className='bg-indigo-400 p-2 rounded-full w-10 items-center flex justify-center transition-colors duration-200 dark:bg-yellow-500 dark:hover:bg-black hover:bg-white'>
54-
{siteConfig('HEO_INFO_CARD_URL', null, CONFIG) && (
55-
<Link href={siteConfig('HEO_INFO_CARD_URL', null, CONFIG)}>
56-
<i className='fab fa-github text-xl' />
52+
{url1 && (
53+
<div className='w-10 text-center bg-indigo-400 p-2 rounded-full transition-colors duration-200 dark:bg-yellow-500 dark:hover:bg-black hover:bg-white'>
54+
<Link href={url1}>
55+
<i className={icon1} />
5756
</Link>
58-
)}
59-
</div>
57+
</div>
58+
)}
59+
{url2 && (
60+
<div className='bg-indigo-400 p-2 rounded-full w-10 items-center flex justify-center transition-colors duration-200 dark:bg-yellow-500 dark:hover:bg-black hover:bg-white'>
61+
<Link href={url2}>
62+
<i className={icon2} />
63+
</Link>
64+
</div>
65+
)}
6066
</div>
67+
{/* 第三个按钮 */}
6168
<MoreButton />
6269
</div>
6370
</Card>
6471
)
6572
}
6673

74+
/**
75+
* 了解更多按鈕
76+
* @returns
77+
*/
78+
function MoreButton() {
79+
const url3 = siteConfig('HEO_INFO_CARD_URL3', null, CONFIG)
80+
const text3 = siteConfig('HEO_INFO_CARD_TEXT3', null, CONFIG)
81+
if (!url3) {
82+
return <></>
83+
}
84+
return (
85+
<Link href={url3}>
86+
<div
87+
className={
88+
'group bg-indigo-400 dark:bg-yellow-500 hover:bg-white dark:hover:bg-black hover:text-black dark:hover:text-white flex items-center transition-colors duration-200 py-2 px-3 rounded-full space-x-1'
89+
}>
90+
<ArrowRightCircle
91+
className={
92+
'group-hover:stroke-black dark:group-hover:stroke-white w-6 h-6 transition-all duration-100'
93+
}
94+
/>
95+
<div className='font-bold'>{text3}</div>
96+
</div>
97+
</Link>
98+
)
99+
}
100+
67101
/**
68102
* 欢迎语
69103
*/
@@ -84,25 +118,3 @@ function GreetingsWords() {
84118
</div>
85119
)
86120
}
87-
88-
/**
89-
* 了解更多按鈕
90-
* @returns
91-
*/
92-
function MoreButton() {
93-
return (
94-
<Link href='/about'>
95-
<div
96-
className={
97-
'group bg-indigo-400 dark:bg-yellow-500 hover:bg-white dark:hover:bg-black hover:text-black dark:hover:text-white flex items-center transition-colors duration-200 py-2 px-3 rounded-full space-x-1'
98-
}>
99-
<ArrowRightCircle
100-
className={
101-
'group-hover:stroke-black dark:group-hover:stroke-white w-6 h-6 transition-all duration-100'
102-
}
103-
/>
104-
<div className='font-bold'>了解更多</div>
105-
</div>
106-
</Link>
107-
)
108-
}

themes/heo/config.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ const CONFIG = {
4242
'🤖️ 数码科技爱好者',
4343
'🧱 团队小组发动机'
4444
],
45-
HEO_INFO_CARD_URL: 'https://github.com/tangly1024/NotionNext', // 个人资料底部按钮链接
45+
46+
// 个人资料底部按钮
47+
HEO_INFO_CARD_URL1: '/about',
48+
HEO_INFO_CARD_ICON1: 'fas fa-user',
49+
HEO_INFO_CARD_URL2: 'https://github.com/tangly1024',
50+
HEO_INFO_CARD_ICON2: 'fab fa-github',
51+
HEO_INFO_CARD_URL3: 'https://www.tangly1024.com',
52+
HEO_INFO_CARD_TEXT3: '了解更多',
4653

4754
// 用户技能图标
4855
HEO_GROUP_ICONS: [

0 commit comments

Comments
 (0)