diff --git a/data/ats.md b/data/ats.md index 1d3f61b5..691309ab 100644 --- a/data/ats.md +++ b/data/ats.md @@ -1,4 +1,4 @@ -欢迎使用 HelloGitHub!HelloGitHub 是一群热爱开源的人(以下简称“我们”)提供的互联网技术服务。 +欢迎访问 HelloGitHub 社区!HelloGitHub 是一群热爱开源的人(以下简称“我们”)提供的互联网技术服务。 ## 一、提示 diff --git a/src/components/home/Item.tsx b/src/components/home/Item.tsx index da778db8..3420a67e 100644 --- a/src/components/home/Item.tsx +++ b/src/components/home/Item.tsx @@ -54,7 +54,7 @@ const Item: NextPage = ({ item }) => {

-
+
{is_hot && ( = ({ item }) => { aria-label='Hot item' /> )} -

+

{name} diff --git a/src/components/layout/Footer.tsx b/src/components/layout/Footer.tsx index c642220e..8fd04719 100644 --- a/src/components/layout/Footer.tsx +++ b/src/components/layout/Footer.tsx @@ -88,7 +88,9 @@ const Footer = () => {

- ©2024 HelloGitHub + + ©{new Date().getFullYear()} HelloGitHub + · = ({ article }) => { return ( <> - - -

+ +
{article.content} @@ -30,7 +29,7 @@ const ArticlePage: NextPage = ({ article }) => { alt='weixin_footer' />
- +
diff --git a/src/pages/article/index.tsx b/src/pages/article/index.tsx index a23b457f..5c81da9e 100644 --- a/src/pages/article/index.tsx +++ b/src/pages/article/index.tsx @@ -24,8 +24,8 @@ import { ArticleItem, ArticleItems } from '@/types/article'; const ArticleIndex: NextPage = () => { const router = useRouter(); const { sort_by = 'last' } = router.query; - const { isLogin } = useLoginContext(); + const { data, error, setSize, isValidating, size } = useSWRInfinite( (index) => makeUrl(`/article/`, { sort_by, page: index + 1 }), @@ -33,34 +33,24 @@ const ArticleIndex: NextPage = () => { { revalidateFirstPage: false } ); - const articles = data - ? data.reduce((pre: ArticleItem[], curr) => { - if (curr.data.length > 0) { - pre.push(...curr.data); - } - return pre; - }, []) - : []; + const articles = data ? data.flatMap((page) => page.data) : []; + const hasMore = data ? data[data.length - 1].has_more : false; - const pageIndex = data ? size : 0; const [sentryRef] = useInfiniteScroll({ loading: isValidating, hasNextPage: hasMore, disabled: !!error, - onLoadMore: () => { - setSize(pageIndex + 1); - }, + onLoadMore: () => setSize((prevSize) => prevSize + 1), rootMargin: '0px 0px 100px 0px', }); const handleItemBottom = () => { if (!isValidating && !hasMore) { - if (isLogin) { - return ; - } else { - return ; - } + const endText = isLogin + ? '你不经意间触碰到了底线' + : '到底啦!登录可查看更多内容'; + return ; } }; @@ -75,62 +65,45 @@ const ArticleIndex: NextPage = () => {
{articles.map((item: ArticleItem) => (
- - -
-
-
-
+ + +
+ )} {handleItemBottom()} diff --git a/src/pages/help/ats.tsx b/src/pages/help/ats.tsx index 79b7f2da..2ba92188 100644 --- a/src/pages/help/ats.tsx +++ b/src/pages/help/ats.tsx @@ -1,35 +1,35 @@ -import { NextPage } from 'next'; +import { GetStaticProps, NextPage } from 'next'; import ItemBottom from '@/components/home/ItemBottom'; import Seo from '@/components/Seo'; import ToTop from '@/components/toTop/ToTop'; -import content from '../../../data/ats.md'; - import { HelpPageProps } from '@/types/help'; const ATSPage: NextPage = ({ content }) => { return ( <> - -
-
+
+
用户服务协议
{content}
- +
-
+
); }; export default ATSPage; -export async function getStaticProps() { +export const getStaticProps: GetStaticProps = async () => { + const content = await import('../../../data/ats.md').then( + (mod) => mod.default + ); return { - props: { content: content }, + props: { content }, }; -} +}; diff --git a/src/pages/help/level.tsx b/src/pages/help/level.tsx index 0b8b9b0c..93e3279e 100644 --- a/src/pages/help/level.tsx +++ b/src/pages/help/level.tsx @@ -1,4 +1,4 @@ -import { NextPage } from 'next'; +import { GetStaticProps, NextPage } from 'next'; import ItemBottom from '@/components/home/ItemBottom'; import { MDRender } from '@/components/mdRender/MDRender'; @@ -6,8 +6,6 @@ import Navbar from '@/components/navbar/Navbar'; import Seo from '@/components/Seo'; import ToTop from '@/components/toTop/ToTop'; -import content from '../../../data/level.md'; - import { HelpPageProps } from '@/types/help'; const RulePage: NextPage = ({ content }) => { @@ -16,24 +14,27 @@ const RulePage: NextPage = ({ content }) => { -
+
{content}
- +
-
+
); }; export default RulePage; -export async function getStaticProps() { +export const getStaticProps: GetStaticProps = async () => { + const content = await import('../../../data/level.md').then( + (mod) => mod.default + ); return { - props: { content: content }, + props: { content }, }; -} +};