+ {siteConfig('POST_TITLE_ICON') && }
+ {post.title}
+
+
+
+
+
{siteConfig('POST_TITLE_ICON') && (
)}
@@ -75,7 +75,7 @@ const BlogPostCardTop = ({ post, showSummary }) => {
{(!showPreview || showSummary) && (
-
+
{post.summary}
)}
@@ -103,4 +103,4 @@ const BlogPostCardTop = ({ post, showSummary }) => {
)
}
-export default BlogPostCardTop
+export default PostItemCardTop
diff --git a/themes/magzine/components/BlogPostCardHorizontal.js b/themes/magzine/components/PostItemCardWide.js
similarity index 77%
rename from themes/magzine/components/BlogPostCardHorizontal.js
rename to themes/magzine/components/PostItemCardWide.js
index 076b2d89..0b250850 100644
--- a/themes/magzine/components/BlogPostCardHorizontal.js
+++ b/themes/magzine/components/PostItemCardWide.js
@@ -8,21 +8,24 @@ import CONFIG from '../config'
import CategoryItem from './CategoryItem'
import TagItemMini from './TagItemMini'
-const BlogPostCardHorizontal = ({ post, showSummary }) => {
+/**
+ * 水平左右布局的博客卡片
+ * @param {*} param0
+ * @returns
+ */
+const PostItemCardWide = ({ post, showSummary }) => {
const showPreview =
- siteConfig('MEDIUM_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap
+ siteConfig('MAGZINE_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap
const { locale } = useGlobal()
return (
-
+
{/* 卡牌左侧 */}
{siteConfig('POST_TITLE_ICON') && (
@@ -32,22 +35,8 @@ const BlogPostCardHorizontal = ({ post, showSummary }) => {
-
- {post.date?.start_date}
- {siteConfig('MEDIUM_POST_LIST_CATEGORY', null, CONFIG) && (
-
- )}
- {siteConfig('MEDIUM_POST_LIST_TAG', null, CONFIG) &&
- post?.tagItems?.map(tag => (
-
- ))}
-
-
{(!showPreview || showSummary) && (
-
+
{post.summary}
)}
@@ -68,6 +57,20 @@ const BlogPostCardHorizontal = ({ post, showSummary }) => {
)}
+
+
+ {siteConfig('MAGZINE_POST_LIST_CATEGORY', null, CONFIG) && (
+
+ )}
+ {siteConfig('MAGZINE_POST_LIST_TAG', null, CONFIG) &&
+ post?.tagItems?.map(tag => (
+
+ ))}
+ {post.date?.start_date}
+
{/* 卡牌右侧图片 */}
@@ -82,4 +85,4 @@ const BlogPostCardHorizontal = ({ post, showSummary }) => {
)
}
-export default BlogPostCardHorizontal
+export default PostItemCardWide
diff --git a/themes/magzine/components/PostListEmpty.js b/themes/magzine/components/PostListEmpty.js
new file mode 100644
index 00000000..cc037cea
--- /dev/null
+++ b/themes/magzine/components/PostListEmpty.js
@@ -0,0 +1,19 @@
+import { useGlobal } from '@/lib/global'
+
+/**
+ * 空白博客 列表
+ * @returns {JSX.Element}
+ * @constructor
+ */
+const PostListEmpty = ({ currentSearch }) => {
+ const { locale } = useGlobal()
+ return (
+
+
+ {locale.COMMON.NO_RESULTS_FOUND}{' '}
+ {currentSearch &&
{currentSearch}}
+
+
+ )
+}
+export default PostListEmpty
diff --git a/themes/magzine/components/PostListHorizontal.js b/themes/magzine/components/PostListHorizontal.js
new file mode 100644
index 00000000..41ef905d
--- /dev/null
+++ b/themes/magzine/components/PostListHorizontal.js
@@ -0,0 +1,38 @@
+import Link from 'next/link'
+import PostItemCardSimple from './PostItemCardSimple'
+import PostListEmpty from './PostListEmpty'
+
+/**
+ * 博文水平列表
+ * 含封面
+ * @returns {JSX.Element}
+ * @constructor
+ */
+const PostListHorizontal = ({ title, href, posts }) => {
+ if (!posts || posts.length === 0) {
+ return
+ }
+
+ return (
+
+
+ {/* 标题 */}
+
+ {title}
+
+ 查看全部
+
+
+
+ {/* 列表 */}
+
+ {posts?.map(p => {
+ return
+ })}
+
+
+
+ )
+}
+
+export default PostListHorizontal
diff --git a/themes/magzine/components/BlogPostListPage.js b/themes/magzine/components/PostListPage.js
similarity index 73%
rename from themes/magzine/components/BlogPostListPage.js
rename to themes/magzine/components/PostListPage.js
index 79e031dd..9486f6ec 100644
--- a/themes/magzine/components/BlogPostListPage.js
+++ b/themes/magzine/components/PostListPage.js
@@ -1,8 +1,8 @@
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
-import BlogPostCard from './BlogPostCard'
-import BlogPostListEmpty from './BlogPostListEmpty'
import PaginationSimple from './PaginationSimple'
+import PostItemCard from './PostItemCard'
+import PostListEmpty from './PostListEmpty'
/**
* 文章列表分页表格
@@ -12,13 +12,13 @@ import PaginationSimple from './PaginationSimple'
* @returns {JSX.Element}
* @constructor
*/
-const BlogPostListPage = ({ page = 1, posts = [], postCount }) => {
+const PostListPage = ({ page = 1, posts = [], postCount }) => {
const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
if (!posts || posts.length === 0) {
- return
+ return
}
return (
@@ -26,7 +26,7 @@ const BlogPostListPage = ({ page = 1, posts = [], postCount }) => {
{/* 文章列表 */}
{posts?.map(post => (
-
+
))}
@@ -34,4 +34,4 @@ const BlogPostListPage = ({ page = 1, posts = [], postCount }) => {
)
}
-export default BlogPostListPage
+export default PostListPage
diff --git a/themes/magzine/components/BlogPostListScroll.js b/themes/magzine/components/PostListScroll.js
similarity index 89%
rename from themes/magzine/components/BlogPostListScroll.js
rename to themes/magzine/components/PostListScroll.js
index 22960779..a33aa1e9 100644
--- a/themes/magzine/components/BlogPostListScroll.js
+++ b/themes/magzine/components/PostListScroll.js
@@ -3,8 +3,8 @@ import { useGlobal } from '@/lib/global'
import throttle from 'lodash.throttle'
import { useRouter } from 'next/router'
import { useCallback, useEffect, useRef, useState } from 'react'
-import BlogPostCard from './BlogPostCard'
-import BlogPostListEmpty from './BlogPostListEmpty'
+import PostItemCard from './PostItemCard'
+import PostListEmpty from './PostListEmpty'
/**
* 博客列表滚动分页
@@ -13,7 +13,7 @@ import BlogPostListEmpty from './BlogPostListEmpty'
* @returns {JSX.Element}
* @constructor
*/
-const BlogPostListScroll = ({ posts = [], currentSearch }) => {
+const PostListScroll = ({ posts = [], currentSearch }) => {
const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const [page, updatePage] = useState(1)
@@ -67,14 +67,14 @@ const BlogPostListScroll = ({ posts = [], currentSearch }) => {
const { locale } = useGlobal()
if (!postsToShow || postsToShow.length === 0) {
- return
+ return
} else {
return (
{/* 文章列表 */}
{postsToShow?.map(post => (
-
+
))}
@@ -104,4 +104,4 @@ const getPostByPage = function (page, totalPosts, POSTS_PER_PAGE) {
return totalPosts.slice(0, POSTS_PER_PAGE * page)
}
-export default BlogPostListScroll
+export default PostListScroll
diff --git a/themes/magzine/components/PostListSimpleHorizontal.js b/themes/magzine/components/PostListSimpleHorizontal.js
new file mode 100644
index 00000000..5add570c
--- /dev/null
+++ b/themes/magzine/components/PostListSimpleHorizontal.js
@@ -0,0 +1,37 @@
+import Link from 'next/link'
+import PostItemCardSimple from './PostItemCardSimple'
+import PostListEmpty from './PostListEmpty'
+
+/**
+ * 博文水平列表;不带封面图
+ * @returns {JSX.Element}
+ * @constructor
+ */
+const PostSimpleListHorizontal = ({ title, href, posts }) => {
+ if (!posts || posts.length === 0) {
+ return
+ }
+
+ return (
+
+
+ {/* 标题 */}
+
+ {title}
+
+ 查看全部
+
+
+
+ {/* 列表 */}
+
+ {posts?.map(p => {
+ return
+ })}
+
+
+
+ )
+}
+
+export default PostSimpleListHorizontal
diff --git a/themes/magzine/components/BlogPostBar.js b/themes/magzine/components/PostListSlotBar.js
similarity index 92%
rename from themes/magzine/components/BlogPostBar.js
rename to themes/magzine/components/PostListSlotBar.js
index 9f34aca5..228d1f3c 100644
--- a/themes/magzine/components/BlogPostBar.js
+++ b/themes/magzine/components/PostListSlotBar.js
@@ -5,7 +5,7 @@ import { useGlobal } from '@/lib/global'
* @param {*} props
* @returns
*/
-export default function BlogPostBar(props) {
+export default function PostListSlotBar(props) {
const { tag, category } = props
const { locale } = useGlobal()
diff --git a/themes/magzine/components/SearchInput.js b/themes/magzine/components/SearchInput.js
index f6c84d9c..4ebcade0 100644
--- a/themes/magzine/components/SearchInput.js
+++ b/themes/magzine/components/SearchInput.js
@@ -21,14 +21,15 @@ const SearchInput = ({ currentTag, currentSearch, cRef, className }) => {
setLoadingState(true)
location.href = '/search/' + key
} else {
- router.push({ pathname: '/' }).then(r => {
- })
+ router.push({ pathname: '/' }).then(r => {})
}
}
- const handleKeyUp = (e) => {
- if (e.keyCode === 13) { // 回车
+ const handleKeyUp = e => {
+ if (e.keyCode === 13) {
+ // 回车
handleSearch(searchInputRef.current.value)
- } else if (e.keyCode === 27) { // ESC
+ } else if (e.keyCode === 27) {
+ // ESC
cleanSearch()
}
}
@@ -37,7 +38,7 @@ const SearchInput = ({ currentTag, currentSearch, cRef, className }) => {
}
const [showClean, setShowClean] = useState(false)
- const updateSearchKey = (val) => {
+ const updateSearchKey = val => {
if (lock) {
return
}
@@ -49,38 +50,48 @@ const SearchInput = ({ currentTag, currentSearch, cRef, className }) => {
setShowClean(false)
}
}
- function lockSearchInput () {
+ function lockSearchInput() {
lock = true
}
- function unLockSearchInput () {
+ function unLockSearchInput() {
lock = false
}
- return
- updateSearchKey(e.target.value)}
- defaultValue={currentSearch}
- />
+ return (
+
+ updateSearchKey(e.target.value)}
+ defaultValue={currentSearch}
+ />
-
-
-
-
- {(showClean &&
-
-
+
+
+
+ {showClean && (
+
+
+
)}
-
+
+ )
}
export default SearchInput
diff --git a/themes/magzine/components/TagItemMini.js b/themes/magzine/components/TagItemMini.js
index 9922a069..c08b33f1 100644
--- a/themes/magzine/components/TagItemMini.js
+++ b/themes/magzine/components/TagItemMini.js
@@ -8,12 +8,15 @@ const TagItemMini = ({ tag, selected = false }) => {
passHref
className={`cursor-pointer inline-block rounded hover:bg-gray-500 hover:text-white duration-200
mr-2 py-1 px-2 text-xs whitespace-nowrap dark:hover:text-white
- ${selected
- ? 'text-white dark:text-gray-300 bg-black dark:bg-black dark:hover:bg-gray-900'
- : `text-gray-600 hover:shadow-xl dark:border-gray-400 notion-${tag.color}_background dark:bg-gray-800`}` }>
-
- {selected && } {tag.name + (tag.count ? `(${tag.count})` : '')}
-
+ ${
+ selected
+ ? 'text-white dark:text-gray-300 dark:hover:bg-gray-900'
+ : `text-gray-900 hover:shadow-xl dark:border-gray-400 dark:bg-gray-800`
+ }`}>
+
+ {/* {selected && } */}#
+ {tag.name + (tag.count ? `(${tag.count})` : '')}{' '}
+
)
}
diff --git a/themes/magzine/components/TopNavBar.js b/themes/magzine/components/TopNavBar.js
index 244a02d7..ef22aa2d 100644
--- a/themes/magzine/components/TopNavBar.js
+++ b/themes/magzine/components/TopNavBar.js
@@ -24,25 +24,25 @@ export default function TopNavBar(props) {
icon: 'fas fa-th',
name: locale.COMMON.CATEGORY,
href: '/category',
- show: siteConfig('MEDIUM_MENU_CATEGORY', null, CONFIG)
+ show: siteConfig('MAGZINE_MENU_CATEGORY', null, CONFIG)
},
{
icon: 'fas fa-tag',
name: locale.COMMON.TAGS,
href: '/tag',
- show: siteConfig('MEDIUM_MENU_TAG', null, CONFIG)
+ show: siteConfig('MAGZINE_MENU_TAG', null, CONFIG)
},
{
icon: 'fas fa-archive',
name: locale.NAV.ARCHIVE,
href: '/archive',
- show: siteConfig('MEDIUM_MENU_ARCHIVE', null, CONFIG)
+ show: siteConfig('MAGZINE_MENU_ARCHIVE', null, CONFIG)
},
{
icon: 'fas fa-search',
name: locale.NAV.SEARCH,
href: '/search',
- show: siteConfig('MEDIUM_MENU_SEARCH', null, CONFIG)
+ show: siteConfig('MAGZINE_MENU_SEARCH', null, CONFIG)
}
]
diff --git a/themes/magzine/config.js b/themes/magzine/config.js
index c29a2ef2..6ef5e66e 100644
--- a/themes/magzine/config.js
+++ b/themes/magzine/config.js
@@ -1,24 +1,35 @@
const CONFIG = {
+ // 首屏信息栏按钮文字
+ MAGZINE_HOME_BANNER_ENABLE: true, // 首屏右上角的宣传位
+ MAGZINE_HOME_BUTTON: true,
+ MAGZINE_HOME_BUTTON_URL: '/about',
+ MAGZINE_HOME_BUTTON_TEXT: '了解更多',
+
+ MAGZINE_HOME_TITLE: '立即开创您的在线业务。完全免费。',
+ MAGZINE_HOME_DESCRIPTION:
+ '借助NotionNext,获得助您开创、经营和扩展业务所需的全部工具和帮助。',
+ MAGZINE_HOME_TIPS: 'AI时代来临,这是属于超级个体的狂欢盛宴!',
// Style
- MEDIUM_RIGHT_PANEL_DARK: process.env.NEXT_PUBLIC_MEDIUM_RIGHT_DARK || false, // 右侧面板深色模式
+ MAGZINE_RIGHT_PANEL_DARK: process.env.NEXT_PUBLIC_MAGZINE_RIGHT_DARK || false, // 右侧面板深色模式
- MEDIUM_POST_LIST_COVER: true, // 文章列表显示图片封面
- MEDIUM_POST_LIST_PREVIEW: true, // 列表显示文章预览
- MEDIUM_POST_LIST_CATEGORY: true, // 列表显示文章分类
- MEDIUM_POST_LIST_TAG: true, // 列表显示文章标签
+ MAGZINE_POST_LIST_COVER: true, // 文章列表显示图片封面
+ MAGZINE_POST_LIST_PREVIEW: true, // 列表显示文章预览
+ MAGZINE_POST_LIST_CATEGORY: true, // 列表显示文章分类
+ MAGZINE_POST_LIST_TAG: true, // 列表显示文章标签
- MEDIUM_POST_DETAIL_CATEGORY: true, // 文章显示分类
- MEDIUM_POST_DETAIL_TAG: true, // 文章显示标签
+ MAGZINE_POST_DETAIL_CATEGORY: true, // 文章显示分类
+ MAGZINE_POST_DETAIL_TAG: true, // 文章显示标签
// 菜单
- MEDIUM_MENU_CATEGORY: true, // 显示分类
- MEDIUM_MENU_TAG: true, // 显示标签
- MEDIUM_MENU_ARCHIVE: true, // 显示归档
- MEDIUM_MENU_SEARCH: true, // 显示搜索
+ MAGZINE_MENU_CATEGORY: true, // 显示分类
+ MAGZINE_MENU_TAG: true, // 显示标签
+ MAGZINE_MENU_ARCHIVE: true, // 显示归档
+ MAGZINE_MENU_SEARCH: true, // 显示搜索
// Widget
- MEDIUM_WIDGET_REVOLVER_MAPS: process.env.NEXT_PUBLIC_WIDGET_REVOLVER_MAPS || 'false', // 地图插件
- MEDIUM_WIDGET_TO_TOP: true // 跳回顶部
+ MAGZINE_WIDGET_REVOLVER_MAPS:
+ process.env.NEXT_PUBLIC_WIDGET_REVOLVER_MAPS || 'false', // 地图插件
+ MAGZINE_WIDGET_TO_TOP: true // 跳回顶部
}
export default CONFIG
diff --git a/themes/magzine/index.js b/themes/magzine/index.js
index db46d13e..5845e01c 100644
--- a/themes/magzine/index.js
+++ b/themes/magzine/index.js
@@ -8,21 +8,20 @@ import { isBrowser } from '@/lib/utils'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { createContext, useContext, useEffect, useState } from 'react'
-import Announcement from './components/Announcement'
+import ArchiveItem from './components/ArchiveItem'
import ArticleAround from './components/ArticleAround'
import ArticleInfo from './components/ArticleInfo'
import { ArticleLock } from './components/ArticleLock'
-import BlogArchiveItem from './components/BlogArchiveItem'
-import BlogPostCardHorizontal from './components/BlogPostCardHorizontal'
-import BlogPostCardTop from './components/BlogPostCardTop'
-import BlogPostListPage from './components/BlogPostListPage'
-import BlogPostListScroll from './components/BlogPostListScroll'
import Catalog from './components/Catalog'
import CategoryGroup from './components/CategoryGroup'
import CategoryItem from './components/CategoryItem'
import Footer from './components/Footer'
import Header from './components/Header'
-import InfoCard from './components/InfoCard'
+import Hero from './components/Hero'
+import PostListHorizontal from './components/PostListHorizontal'
+import PostListPage from './components/PostListPage'
+import PostListScroll from './components/PostListScroll'
+import PostSimpleListHorizontal from './components/PostListSimpleHorizontal'
import SearchInput from './components/SearchInput'
import TagGroups from './components/TagGroups'
import TagItemMini from './components/TagItemMini'
@@ -81,33 +80,72 @@ const LayoutBase = props => {
* @returns
*/
const LayoutIndex = props => {
- const { posts, notice } = props
- const top = posts[0]
- const post1 = posts[1]
- const post2 = posts[2]
- return (
-
- {/* 首屏文章 */}
+ const { posts, allNavPages } = props
+ // 最新文章 从第4个元素开始截取出4个
+ const newPosts = posts.slice(3, 7)
-
-
-
-
-
-
-
-
-
- {/* 两篇主要文章 */}
-
-
-
-
-
-
+ // 按分类将文章分组成文件夹
+ const categoryFolders = groupArticles(allNavPages.slice(8))
+
+ return (
+
+ {/* 首屏宣传区块 */}
+
+
+ {/* 最新文章区块 */}
+
+
+ {/* 不同的分类文章列表 */}
+ {categoryFolders?.map((categoryGroup, index) => {
+ if (
+ !categoryGroup ||
+ !categoryGroup.items ||
+ categoryGroup.items.length < 1
+ ) {
+ return null
+ }
+
+ return (
+
+ )
+ })}
)
}
+// 按照分类将文章分组成文件夹
+function groupArticles(allPosts) {
+ if (!allPosts) {
+ return []
+ }
+ const groups = []
+
+ for (let i = 0; i < allPosts.length; i++) {
+ const item = allPosts[i]
+ const categoryName = item?.category ? item?.category : '' // 将 category 转换为字符串
+
+ let existingGroup = groups.find(group => group.category === categoryName) // 搜索同名的最后一个分组
+
+ if (existingGroup && existingGroup.category === categoryName) {
+ // 如果分组已存在,并且该分组中的文章数量小于4,添加文章
+ if (existingGroup.items.length < 4) {
+ existingGroup.items.push(item)
+ }
+ } else {
+ // 新建分组,并添加当前文章
+ groups.push({ category: categoryName, items: [item] })
+ }
+ }
+
+ return groups
+}
/**
* 博客列表
@@ -117,9 +155,9 @@ const LayoutPostList = props => {
return (
<>
{siteConfig('POST_LIST_STYLE') === 'page' ? (
-
+
) : (
-
+
)}
>
)
@@ -180,10 +218,10 @@ const LayoutSlug = props => {
{/* 文章分类和标签信息 */}
- {siteConfig('MEDIUM_POST_DETAIL_CATEGORY', null, CONFIG) &&
+ {siteConfig('MAGZINE_POST_DETAIL_CATEGORY', null, CONFIG) &&
post?.category && }
- {siteConfig('MEDIUM_POST_DETAIL_TAG', null, CONFIG) &&
+ {siteConfig('MAGZINE_POST_DETAIL_TAG', null, CONFIG) &&
post?.tagItems?.map(tag => (
))}
@@ -245,9 +283,9 @@ const LayoutSearch = props => {
{currentSearch && (
{siteConfig('POST_LIST_STYLE') === 'page' ? (
-
+
) : (
-
+
)}
)}
@@ -266,7 +304,7 @@ const LayoutArchive = props => {
<>
{Object.keys(archivePosts)?.map(archiveTitle => (
-
{siteConfig('POST_TITLE_ICON') && ( @@ -32,22 +35,8 @@ const BlogPostCardHorizontal = ({ post, showSummary }) => {
-+ {locale.COMMON.NO_RESULTS_FOUND}{' '} + {currentSearch &&
{title}
+ + 查看全部 + + +-
+ {posts?.map(p => {
+ return
{title}
+ + 查看全部 + + +-
+ {posts?.map(p => {
+ return