Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion components/ShareButtons.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import dynamic from 'next/dynamic'
import Image from 'next/image'
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'

Expand Down Expand Up @@ -86,7 +87,14 @@ const ShareButtons = ({ post }) => {
const closePopover = () => {
setQrCodeShow(false)
}

const openRedirectShare = base => {
if (!shareUrl || typeof window === 'undefined') return
window.open(
`${base}${encodeURIComponent(shareUrl)}`,
'_blank',
'noopener,noreferrer'
)
}
useEffect(() => {
setShareUrl(window.location.href)
}, [])
Expand Down Expand Up @@ -377,6 +385,47 @@ const ShareButtons = ({ post }) => {
</div>
</button>
)
case 'csdn':
return (
<button
aria-label={singleService}
key={singleService}
onClick={() => openRedirectShare('https://link.csdn.net/?target=')}
className='cursor-pointer rounded-full mx-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-500'>
<div className='w-8 h-8 rounded-full items-center justify-center'
style={{backgroundColor: '#ff6a00'}}>
<Image
src='/svg/csdn.svg'
alt='CSDN'
width={28}
height={28}
className='w-5 h-5'
loading='lazy'
style={{ transform: 'translateY(3px)' }}
/>
</div>
</button>
)
case 'juejin':
return (
<button
aria-label={singleService}
key={singleService}
onClick={() => openRedirectShare('https://link.juejin.cn/?target=')}
className='cursor-pointer rounded-full mx-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500'>
<div className='w-8 h-8 rounded-full flex items-center justify-center'
style={{ backgroundColor: '#5dade2' }}>
<Image
src='/svg/juejin.svg'
alt='掘金'
width={24}
height={24}
className='w-5 h-5'
loading='lazy'
/>
</div>
</button>
)
default:
return <></>
}
Expand Down
2 changes: 1 addition & 1 deletion conf/post.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
POST_SHARE_BAR_ENABLE: process.env.NEXT_PUBLIC_POST_SHARE_BAR || 'true', //文章底部分享条开关
POSTS_SHARE_SERVICES:
process.env.NEXT_PUBLIC_POST_SHARE_SERVICES ||
'link,wechat,qq,weibo,email,facebook,twitter,telegram,messenger,line,reddit,whatsapp,linkedin', // 分享的服務,按顺序显示,逗号隔开
'link,wechat,qq,weibo,email,facebook,twitter,telegram,messenger,line,reddit,whatsapp,linkedin,csdn,juejin', // 分享的服務,按顺序显示,逗号隔开
// 所有支持的分享服务:link(复制链接),wechat(微信),qq,weibo(微博),email(邮件),facebook,twitter,telegram,messenger,line,reddit,whatsapp,linkedin,vkshare,okshare,tumblr,livejournal,mailru,viber,workplace,pocket,instapaper,hatena

POST_TITLE_ICON: process.env.NEXT_PUBLIC_POST_TITLE_ICON || true, // 是否显示标题icon
Expand Down
16 changes: 16 additions & 0 deletions public/svg/csdn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions public/svg/juejin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.