diff --git a/src/components/periodical/item.tsx b/src/components/periodical/item.tsx index e3d6f10a..788598ae 100644 --- a/src/components/periodical/item.tsx +++ b/src/components/periodical/item.tsx @@ -72,9 +72,7 @@ const PeriodItem: NextPage = ({ item, index }) => { {/* markdown 内容渲染 */} {i18n.language == 'en' - ? item.description_en - ? item.description_en - : item.description + ? item.description_en || item.description : item.description} {/* 图片预览 */} diff --git a/src/components/respository/Info.tsx b/src/components/respository/Info.tsx index ea1d9457..a3816065 100644 --- a/src/components/respository/Info.tsx +++ b/src/components/respository/Info.tsx @@ -343,7 +343,7 @@ const Info = ({ repo, t, i18n_lang }: RepositoryProps) => {
-
+
handleClickLink('source', repo.rid)} diff --git a/src/components/respository/Tabs.tsx b/src/components/respository/Tabs.tsx index e6ff3968..4773311b 100644 --- a/src/components/respository/Tabs.tsx +++ b/src/components/respository/Tabs.tsx @@ -65,7 +65,9 @@ const Tabs = ({ repo, t, i18n_lang }: RepositoryProps) => { >
- {item.name} + {i18n_lang == 'en' + ? item.name_en || item.name + : item.name}
diff --git a/src/components/side/UserStatus.tsx b/src/components/side/UserStatus.tsx index c690923b..15b02d36 100644 --- a/src/components/side/UserStatus.tsx +++ b/src/components/side/UserStatus.tsx @@ -54,18 +54,21 @@ export default function UserStatus({ t }: SideProps) {
{ router.push('/notification'); }} > - + {userInfo?.unread.total > 0 && ( - + + + + )}
diff --git a/src/pages/server-sitemap-index.xml/index.tsx b/src/pages/server-sitemap-index.xml/index.tsx index 7422d259..8a1752a9 100644 --- a/src/pages/server-sitemap-index.xml/index.tsx +++ b/src/pages/server-sitemap-index.xml/index.tsx @@ -2,17 +2,19 @@ import { GetServerSideProps, GetServerSidePropsContext } from 'next'; import { getServerSideSitemap, ISitemapField } from 'next-sitemap'; -import { getURLs } from '@/services/sitemap'; +import { getSitemap } from '@/services/home'; export const getServerSideProps: GetServerSideProps = async ( ctx: GetServerSidePropsContext ) => { // Method to source urls from cms - const data = await getURLs(); - const allURLs = data?.data.map((url) => { + const data = await getSitemap(); + const allURLs = data?.data.map((item) => { return { - loc: url, - changefreq: 'weekly', + loc: item.loc, + lastmod: item.lastmod, + priority: item.priority, + changefreq: item.changefreq, } as ISitemapField; }); return getServerSideSitemap(ctx, allURLs); diff --git a/src/services/home.ts b/src/services/home.ts index 008d5474..529280ab 100644 --- a/src/services/home.ts +++ b/src/services/home.ts @@ -4,7 +4,13 @@ import { makeUrl } from '@/utils/api'; import { fetcher } from './base'; -import { HomeItem, HomeItems, RecommendItems, Stats } from '@/types/home'; +import { + HomeItem, + HomeItems, + RecommendItems, + Sitemap, + Stats, +} from '@/types/home'; import { TagItems } from '@/types/tag'; export const getItems = async ( @@ -87,3 +93,8 @@ export const createFeedback = async (data: { }; export type HomeItemData = HomeItem[]; export const DataContext = createContext([]); + +export const getSitemap = async (): Promise => { + const data = await fetcher(makeUrl(`/sitemap/`)); + return data; +}; diff --git a/src/services/sitemap.ts b/src/services/sitemap.ts deleted file mode 100644 index fb786445..00000000 --- a/src/services/sitemap.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { makeUrl } from '@/utils/api'; - -import { fetcher } from './base'; - -interface URLs { - success: boolean; - data: []; -} - -export const getURLs = async (): Promise => { - const data = await fetcher(makeUrl(`/sitemap/`)); - return data; -}; diff --git a/src/types/home.tsx b/src/types/home.tsx index 5e3bd0a6..83cec704 100644 --- a/src/types/home.tsx +++ b/src/types/home.tsx @@ -74,3 +74,15 @@ export interface CreateFeedbackRes { message: string; success: boolean; } + +export interface SitemapItem { + loc: string; + lastmod?: string; + changefreq?: string; + priority?: number; +} + +export interface Sitemap { + success: boolean; + data: SitemapItem[]; +} diff --git a/src/types/tag.tsx b/src/types/tag.tsx index 03b4302b..8df52bd1 100644 --- a/src/types/tag.tsx +++ b/src/types/tag.tsx @@ -44,6 +44,7 @@ export interface SelectTagItems { export interface TagType { name: string; + name_en: string; tid: string; }