Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #71

Merged
merged 24 commits into from
Oct 13, 2024
Merged

Dev #71

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5b18451
修复错误的标签
tangly1024 Oct 8, 2024
d26bbf5
Merge pull request #2831 from tangly1024/fix/tag-language
tangly1024 Oct 8, 2024
6c452c2
分页多语言
tangly1024 Oct 8, 2024
6dbeba4
Merge pull request #2832 from tangly1024/fix/language-page
tangly1024 Oct 8, 2024
e1bead3
修复heo主题文字遮挡
tangly1024 Oct 8, 2024
0dd7548
Merge pull request #2833 from tangly1024/fix/heo-hero-banner-title-z-…
tangly1024 Oct 8, 2024
1f255c5
修复菜单自定义名的bug
tangly1024 Oct 8, 2024
eed528a
Merge pull request #2834 from tangly1024/fix/custom-menu
tangly1024 Oct 8, 2024
4400400
4.7.5
tangly1024 Oct 8, 2024
914443a
Merge pull request #2835 from tangly1024/release/4.7.5
tangly1024 Oct 8, 2024
1ad7274
heo 英雄区
tangly1024 Oct 9, 2024
fc0e98b
Merge pull request #2836 from tangly1024/release/4.7.5
tangly1024 Oct 9, 2024
dbe9057
starter主题的社交按钮配置
tangly1024 Oct 10, 2024
42c294c
Merge pull request #2844 from tangly1024/release/4.7.5
tangly1024 Oct 10, 2024
d9b71bc
Starter 英雄区配图
tangly1024 Oct 11, 2024
aa85f6c
Merge pull request #2853 from tangly1024/release/4.7.5
tangly1024 Oct 11, 2024
006d411
banner图全宽
tangly1024 Oct 11, 2024
f24e82b
starter - hero banner 宽度限制
tangly1024 Oct 11, 2024
3b360d0
默认关闭banner
tangly1024 Oct 11, 2024
cd3ac58
starter 合作伙伴模块上移
tangly1024 Oct 11, 2024
3a91bdb
fix
tangly1024 Oct 11, 2024
b8f5810
fix
tangly1024 Oct 11, 2024
675def4
starter主题,空图片处理
tangly1024 Oct 12, 2024
5bf2910
Merge branch 'main' into dev
lifeafter619 Oct 13, 2024
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
2 changes: 1 addition & 1 deletion .env.local
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables
NEXT_PUBLIC_VERSION=4.7.4
NEXT_PUBLIC_VERSION=4.7.5


# 可在此添加环境变量,去掉最左边的(# )注释即可
Expand Down
45 changes: 41 additions & 4 deletions lib/db/getSiteData.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,47 @@ function handleDataBeforeReturn(db) {
db.allNavPages = shortenIds(db?.allNavPages)
// db.allPages = cleanBlocks(db?.allPages)

db.allNavPages = cleanPages(db?.allNavPages, db.tagOptions)
db.allPages = cleanPages(db.allPages, db.tagOptions)
db.latestPosts = cleanPages(db.latestPosts, db.tagOptions)
return db
}

/**
* 处理文章列表中的异常数据
* @param {Array} allPages - 所有页面数据
* @param {Array} tagOptions - 标签选项
* @returns {Array} 处理后的 allPages
*/
function cleanPages(allPages, tagOptions) {
// 校验参数是否为数组
if (!Array.isArray(allPages) || !Array.isArray(tagOptions)) {
console.warn('Invalid input: allPages and tagOptions should be arrays.')
return allPages || [] // 返回空数组或原始值
}

// 提取 tagOptions 中所有合法的标签名
const validTags = new Set(
tagOptions
.map(tag => (typeof tag.name === 'string' ? tag.name : null))
.filter(Boolean) // 只保留合法的字符串
)

// 遍历所有的 pages
allPages.forEach(page => {
// 确保 tagItems 是数组
if (Array.isArray(page.tagItems)) {
// 对每个 page 的 tagItems 进行过滤
page.tagItems = page.tagItems.filter(
tagItem =>
validTags.has(tagItem?.name) && typeof tagItem.name === 'string' // 校验 tagItem.name 是否是字符串
)
}
})

return allPages
}

/**
* 清理一组数据的id
* @param {*} items
Expand Down Expand Up @@ -237,16 +275,15 @@ function getCustomMenu({ collectionData, NOTION_CONFIG }) {
const menuPages = collectionData.filter(
post =>
post.status === 'Published' &&
(post?.type === BLOG.NOTION_PROPERTY_NAME.type_menu ||
post?.type === BLOG.NOTION_PROPERTY_NAME.type_sub_menu)
(post?.type === 'Menu' || post?.type === 'SubMenu')
)
const menus = []
if (menuPages && menuPages.length > 0) {
menuPages.forEach(e => {
e.show = true
if (e.type === BLOG.NOTION_PROPERTY_NAME.type_menu) {
if (e.type === 'Menu') {
menus.push(e)
} else if (e.type === BLOG.NOTION_PROPERTY_NAME.type_sub_menu) {
} else if (e.type === 'SubMenu') {
const parentMenu = menus[menus.length - 1]
if (parentMenu) {
if (parentMenu.subMenus) {
Expand Down
27 changes: 16 additions & 11 deletions lib/notion/getPageProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,25 @@ function convertToJSON(str) {
* 映射用户自定义表头
*/
function mapProperties(properties) {
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_post) {
properties.type = 'Post'
const typeMap = {
[BLOG.NOTION_PROPERTY_NAME.type_post]: 'Post',
[BLOG.NOTION_PROPERTY_NAME.type_page]: 'Page',
[BLOG.NOTION_PROPERTY_NAME.type_notice]: 'Notice',
[BLOG.NOTION_PROPERTY_NAME.type_menu]: 'Menu',
[BLOG.NOTION_PROPERTY_NAME.type_sub_menu]: 'SubMenu'
}
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_page) {
properties.type = 'Page'
}
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_notice) {
properties.type = 'Notice'

const statusMap = {
[BLOG.NOTION_PROPERTY_NAME.status_publish]: 'Published',
[BLOG.NOTION_PROPERTY_NAME.status_invisible]: 'Invisible'
}
if (properties?.status === BLOG.NOTION_PROPERTY_NAME.status_publish) {
properties.status = 'Published'

if (properties?.type && typeMap[properties.type]) {
properties.type = typeMap[properties.type]
}
if (properties?.status === BLOG.NOTION_PROPERTY_NAME.status_invisible) {
properties.status = 'Invisible'

if (properties?.status && statusMap[properties.status]) {
properties.status = statusMap[properties.status]
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notion-next",
"version": "4.7.4",
"version": "4.7.5",
"homepage": "https://github.com/tangly1024/NotionNext.git",
"license": "MIT",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions pages/page/[page].js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export async function getStaticPaths({ locale }) {
}
}

export async function getStaticProps({ params: { page } }) {
export async function getStaticProps({ params: { page }, locale }) {
const from = `page-${page}`
const props = await getGlobalData({ from })
const props = await getGlobalData({ from, locale })
const { allPages } = props
const POST_PREVIEW_LINES = siteConfig(
'POST_PREVIEW_LINES',
Expand Down
Binary file added public/images/starter/hero/banner.webp
Binary file not shown.
142 changes: 110 additions & 32 deletions themes/fukasawa/components/SocialButton.js
Original file line number Diff line number Diff line change
@@ -1,104 +1,182 @@
import QrCode from '@/components/QrCode'
import { siteConfig } from '@/lib/config'
import { useState } from 'react'

/**
* 社交联系方式按钮组
* @returns {JSX.Element}
* @constructor
*/
const SocialButton = () => {
const CONTACT_GITHUB = siteConfig('CONTACT_GITHUB')
const CONTACT_TWITTER = siteConfig('CONTACT_TWITTER')
const CONTACT_TELEGRAM = siteConfig('CONTACT_TELEGRAM')

const CONTACT_LINKEDIN = siteConfig('CONTACT_LINKEDIN')
const CONTACT_WEIBO = siteConfig('CONTACT_WEIBO')
const CONTACT_INSTAGRAM = siteConfig('CONTACT_INSTAGRAM')
const CONTACT_EMAIL = siteConfig('CONTACT_EMAIL')
const ENABLE_RSS = siteConfig('ENABLE_RSS')
const CONTACT_BILIBILI = siteConfig('CONTACT_BILIBILI')
const CONTACT_YOUTUBE = siteConfig('CONTACT_YOUTUBE')

const CONTACT_XIAOHONGSHU = siteConfig('CONTACT_XIAOHONGSHU')
const CONTACT_ZHISHIXINGQIU = siteConfig('CONTACT_ZHISHIXINGQIU')
const CONTACT_WEHCHAT_PUBLIC = siteConfig('CONTACT_WEHCHAT_PUBLIC')
const [qrCodeShow, setQrCodeShow] = useState(false)

const openPopover = () => {
setQrCodeShow(true)
}
const closePopover = () => {
setQrCodeShow(false)
}

return (
<div className='w-52 flex-wrap flex'>
<div className='space-x-3 text-lg text-gray-500 dark:text-gray-400'>
{siteConfig('CONTACT_GITHUB') && (
<div className='w-full justify-center flex-wrap flex'>
<div className='space-x-3 text-xl flex items-center text-gray-600 dark:text-gray-300 '>
{CONTACT_GITHUB && (
<a
target='_blank'
rel='noreferrer'
title={'github'}
href={siteConfig('CONTACT_GITHUB')}>
<i className='fab fa-github transform hover:scale-125 duration-150' />
href={CONTACT_GITHUB}>
<i className='transform hover:scale-125 duration-150 fab fa-github dark:hover:text-green-400 hover:text-green-600' />
</a>
)}
{siteConfig('CONTACT_TWITTER') && (
{CONTACT_TWITTER && (
<a
target='_blank'
rel='noreferrer'
title={'twitter'}
href={siteConfig('CONTACT_TWITTER')}>
<i className='fab fa-twitter transform hover:scale-125 duration-150' />
href={CONTACT_TWITTER}>
<i className='transform hover:scale-125 duration-150 fab fa-twitter dark:hover:text-green-400 hover:text-green-600' />
</a>
)}
{siteConfig('CONTACT_TELEGRAM') && (
{CONTACT_TELEGRAM && (
<a
target='_blank'
rel='noreferrer'
href={siteConfig('CONTACT_TELEGRAM')}
href={CONTACT_TELEGRAM}
title={'telegram'}>
<i className='fab fa-telegram transform hover:scale-125 duration-150' />
<i className='transform hover:scale-125 duration-150 fab fa-telegram dark:hover:text-green-400 hover:text-green-600' />
</a>
)}
{siteConfig('CONTACT_LINKEDIN') && (
{CONTACT_LINKEDIN && (
<a
target='_blank'
rel='noreferrer'
href={siteConfig('CONTACT_LINKEDIN')}
title={'linkedIn'}>
<i className='fab fa-linkedin transform hover:scale-125 duration-150' />
href={CONTACT_LINKEDIN}
title={'linkIn'}>
<i className='transform hover:scale-125 duration-150 fab fa-linkedin dark:hover:text-green-400 hover:text-green-600' />
</a>
)}
{siteConfig('CONTACT_WEIBO') && (
{CONTACT_WEIBO && (
<a
target='_blank'
rel='noreferrer'
title={'weibo'}
href={siteConfig('CONTACT_WEIBO')}>
<i className='fab fa-weibo transform hover:scale-125 duration-150' />
href={CONTACT_WEIBO}>
<i className='transform hover:scale-125 duration-150 fab fa-weibo dark:hover:text-green-400 hover:text-green-600' />
</a>
)}
{siteConfig('CONTACT_INSTAGRAM') && (
{CONTACT_INSTAGRAM && (
<a
target='_blank'
rel='noreferrer'
title={'instagram'}
href={siteConfig('CONTACT_INSTAGRAM')}>
<i className='fab fa-instagram transform hover:scale-125 duration-150' />
href={CONTACT_INSTAGRAM}>
<i className='transform hover:scale-125 duration-150 fab fa-instagram dark:hover:text-green-400 hover:text-green-600' />
</a>
)}
{siteConfig('CONTACT_EMAIL') && (
{CONTACT_EMAIL && (
<a
target='_blank'
rel='noreferrer'
title={'email'}
href={`mailto:${siteConfig('CONTACT_EMAIL')}`}>
<i className='fas fa-envelope transform hover:scale-125 duration-150' />
href={`mailto:${CONTACT_EMAIL}`}>
<i className='transform hover:scale-125 duration-150 fas fa-envelope dark:hover:text-green-400 hover:text-green-600' />
</a>
)}
{JSON.parse(siteConfig('ENABLE_RSS')) && (
{ENABLE_RSS && (
<a
target='_blank'
rel='noreferrer'
title={'RSS'}
href={'/rss/feed.xml'}>
<i className='fas fa-rss transform hover:scale-125 duration-150' />
<i className='transform hover:scale-125 duration-150 fas fa-rss dark:hover:text-green-400 hover:text-green-600' />
</a>
)}
{siteConfig('CONTACT_BILIBILI') && (
{CONTACT_BILIBILI && (
<a
target='_blank'
rel='noreferrer'
title={'bilibili'}
href={siteConfig('CONTACT_BILIBILI')}>
<i className='fab fa-bilibili transform hover:scale-125 duration-150' />
href={CONTACT_BILIBILI}>
<i className='transform hover:scale-125 duration-150 dark:hover:text-green-400 hover:text-green-600 fab fa-bilibili' />
</a>
)}
{siteConfig('CONTACT_YOUTUBE') && (
{CONTACT_YOUTUBE && (
<a
target='_blank'
rel='noreferrer'
title={'youtube'}
href={siteConfig('CONTACT_YOUTUBE')}>
<i className='fab fa-youtube transform hover:scale-125 duration-150' />
href={CONTACT_YOUTUBE}>
<i className='transform hover:scale-125 duration-150 fab fa-youtube dark:hover:text-green-400 hover:text-green-600' />
</a>
)}
{CONTACT_XIAOHONGSHU && (
<a
target='_blank'
rel='noreferrer'
title={'小红书'}
href={CONTACT_XIAOHONGSHU}>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
className='transform hover:scale-125 duration-150 w-6'
src='/svg/xiaohongshu.svg'
alt='小红书'
/>
</a>
)}
{CONTACT_ZHISHIXINGQIU && (
<a
target='_blank'
rel='noreferrer'
title={'知识星球'}
className='flex justify-center items-center'
href={CONTACT_ZHISHIXINGQIU}>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
className='transform hover:scale-125 duration-150 w-6'
src='/svg/zhishixingqiu.svg'
alt='知识星球'
/>{' '}
</a>
)}
{CONTACT_WEHCHAT_PUBLIC && (
<button
onMouseEnter={openPopover}
onMouseLeave={closePopover}
aria-label={'微信公众号'}>
<div id='wechat-button'>
<i className='transform scale-105 hover:scale-125 duration-150 fab fa-weixin dark:hover:text-green-400 hover:text-green-600' />
</div>
{/* 二维码弹框 */}
<div className='absolute'>
<div
id='pop'
className={
(qrCodeShow ? 'opacity-100 ' : ' invisible opacity-0') +
' z-40 absolute bottom-10 -left-10 bg-white shadow-xl transition-all duration-200 text-center'
}>
<div className='p-2 mt-1 w-28 h-28'>
{qrCodeShow && <QrCode value={CONTACT_WEHCHAT_PUBLIC} />}
</div>
</div>
</div>
</button>
)}
</div>
</div>
)
Expand Down
19 changes: 12 additions & 7 deletions themes/heo/components/Hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,17 @@ function Banner(props) {
router.push(`${siteConfig('SUB_PATH', '')}/${randomPost?.slug}`)
}

// 遮罩文字
const coverTitle = siteConfig('HEO_HERO_COVER_TITLE')

return (
<div
id='banners'
onClick={handleClickBanner}
className='hidden xl:flex xl:flex-col group h-full bg-white dark:bg-[#1e1e1e] rounded-xl border dark:border-gray-700 mb-3 relative overflow-hidden'>
<div id='banner-title' className='flex flex-col absolute top-10 left-10'>
<div
id='banner-title'
className='z-10 flex flex-col absolute top-10 left-10'>
<div className='text-4xl font-bold mb-3 dark:text-white'>
{siteConfig('HEO_HERO_TITLE_1', null, CONFIG)}
<br />
Expand All @@ -97,10 +102,10 @@ function Banner(props) {
id='banner-cover'
style={{ backdropFilter: 'blur(15px)' }}
className={
'rounded-xl overflow-hidden opacity-0 group-hover:opacity-100 duration-300 transition-all bg-[#4259efdd] dark:bg-[#dca846] dark:text-white cursor-pointer absolute w-full h-full top-0 flex justify-start items-center'
'z-20 rounded-xl overflow-hidden opacity-0 group-hover:opacity-100 duration-300 transition-all bg-[#4259efdd] dark:bg-[#dca846] dark:text-white cursor-pointer absolute w-full h-full top-0 flex justify-start items-center'
}>
<div className='ml-12 -translate-x-32 group-hover:translate-x-0 duration-300 transition-all ease-in'>
<div className='text-7xl text-white font-extrabold'>随便逛逛</div>
<div className='text-7xl text-white font-extrabold'>{coverTitle}</div>
<div className='-ml-3 text-gray-300'>
<ArrowSmallRight className={'w-24 h-24 stroke-2'} />
</div>
Expand All @@ -115,10 +120,10 @@ function Banner(props) {
* 英雄区左上角banner条中斜向滚动的图标
*/
function TagsGroupBar() {
const groupIcons = siteConfig('HEO_GROUP_ICONS', null, CONFIG).concat(
siteConfig('HEO_GROUP_ICONS', null, CONFIG)
)

let groupIcons = siteConfig('HEO_GROUP_ICONS', null, CONFIG)
if (groupIcons) {
groupIcons = groupIcons.concat(groupIcons)
}
return (
<div className='tags-group-all flex -rotate-[30deg] h-full'>
<div className='tags-group-wrapper flex flex-nowrap absolute top-16'>
Expand Down
Loading