Skip to content

Commit 39563d1

Browse files
committed
update: sitemap
1 parent 4d90f3b commit 39563d1

File tree

9 files changed

+43
-27
lines changed

9 files changed

+43
-27
lines changed

src/components/periodical/item.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ const PeriodItem: NextPage<PeriodicalItemProps> = ({ item, index }) => {
7272
{/* markdown 内容渲染 */}
7373
<MDRender className='markdown-body'>
7474
{i18n.language == 'en'
75-
? item.description_en
76-
? item.description_en
77-
: item.description
75+
? item.description_en || item.description
7876
: item.description}
7977
</MDRender>
8078
{/* 图片预览 */}

src/components/respository/Info.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ const Info = ({ repo, t, i18n_lang }: RepositoryProps) => {
343343
</div>
344344
<div className='flex flex-1 flex-row flex-wrap justify-between'>
345345
<div className='mb-2 flex w-full flex-col gap-y-2 md:hidden'>
346-
<div className='flex flex-row items-center '>
346+
<div className='flex flex-row items-center'>
347347
<CustomLink
348348
href={repo.url}
349349
onClick={() => handleClickLink('source', repo.rid)}

src/components/respository/Tabs.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ const Tabs = ({ repo, t, i18n_lang }: RepositoryProps) => {
6565
>
6666
<a>
6767
<div className='mb-1 mr-1 flex h-5 cursor-pointer items-center rounded-xl bg-blue-100 px-2.5 text-xs text-blue-500 hover:bg-blue-200 dark:bg-blue-500 dark:text-gray-100 dark:hover:bg-blue-700 lg:mr-2'>
68-
{item.name}
68+
{i18n_lang == 'en'
69+
? item.name_en || item.name
70+
: item.name}
6971
</div>
7072
</a>
7173
</Link>

src/components/side/UserStatus.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,21 @@ export default function UserStatus({ t }: SideProps) {
5454
<div className='flex-grow' />
5555
<div className='justify-end'>
5656
<div
57-
className='flex flex-row items-center'
57+
className='flex cursor-pointer flex-row'
5858
onClick={() => {
5959
router.push('/notification');
6060
}}
6161
>
62-
<span className='relative inline-flex cursor-pointer'>
62+
<span className='relative inline-block'>
6363
<AiOutlineBell
6464
size={20}
6565
className='text-gray-500 hover:text-blue-500 dark:text-gray-400 dark:hover:text-blue-500'
6666
/>
6767
{userInfo?.unread.total > 0 && (
68-
<span className='relative right-1 inline-flex h-1.5 w-1.5 rounded-full bg-red-500' />
68+
<span className='absolute top-0.5 right-0 flex h-1.5 w-1.5 translate-x-1/2 -translate-y-1/2'>
69+
<span className='absolute inline-flex h-full w-full animate-ping rounded-full bg-blue-400 opacity-75' />
70+
<span className='relative inline-flex h-1.5 w-1.5 rounded-full bg-blue-500' />
71+
</span>
6972
)}
7073
</span>
7174
</div>

src/pages/server-sitemap-index.xml/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
import { GetServerSideProps, GetServerSidePropsContext } from 'next';
33
import { getServerSideSitemap, ISitemapField } from 'next-sitemap';
44

5-
import { getURLs } from '@/services/sitemap';
5+
import { getSitemap } from '@/services/home';
66

77
export const getServerSideProps: GetServerSideProps = async (
88
ctx: GetServerSidePropsContext
99
) => {
1010
// Method to source urls from cms
11-
const data = await getURLs();
12-
const allURLs = data?.data.map((url) => {
11+
const data = await getSitemap();
12+
const allURLs = data?.data.map((item) => {
1313
return {
14-
loc: url,
15-
changefreq: 'weekly',
14+
loc: item.loc,
15+
lastmod: item.lastmod,
16+
priority: item.priority,
17+
changefreq: item.changefreq,
1618
} as ISitemapField;
1719
});
1820
return getServerSideSitemap(ctx, allURLs);

src/services/home.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import { makeUrl } from '@/utils/api';
44

55
import { fetcher } from './base';
66

7-
import { HomeItem, HomeItems, RecommendItems, Stats } from '@/types/home';
7+
import {
8+
HomeItem,
9+
HomeItems,
10+
RecommendItems,
11+
Sitemap,
12+
Stats,
13+
} from '@/types/home';
814
import { TagItems } from '@/types/tag';
915

1016
export const getItems = async (
@@ -87,3 +93,8 @@ export const createFeedback = async (data: {
8793
};
8894
export type HomeItemData = HomeItem[];
8995
export const DataContext = createContext<HomeItemData>([]);
96+
97+
export const getSitemap = async (): Promise<Sitemap> => {
98+
const data = await fetcher<Sitemap>(makeUrl(`/sitemap/`));
99+
return data;
100+
};

src/services/sitemap.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/types/home.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,15 @@ export interface CreateFeedbackRes {
7474
message: string;
7575
success: boolean;
7676
}
77+
78+
export interface SitemapItem {
79+
loc: string;
80+
lastmod?: string;
81+
changefreq?: string;
82+
priority?: number;
83+
}
84+
85+
export interface Sitemap {
86+
success: boolean;
87+
data: SitemapItem[];
88+
}

src/types/tag.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface SelectTagItems {
4444

4545
export interface TagType {
4646
name: string;
47+
name_en: string;
4748
tid: string;
4849
}
4950

0 commit comments

Comments
 (0)