diff --git a/next-sitemap.config.js b/next-sitemap.config.js index 11b2e94..36f1faa 100644 --- a/next-sitemap.config.js +++ b/next-sitemap.config.js @@ -9,7 +9,13 @@ module.exports = { changefreq: 'daily', priority: 0.7, generateRobotsTxt: true, - exclude: ['/tachi', '/help', '/search'], + exclude: [ + '/tachi', + '/user/login', + '/help', + '*/search*', + '*/periodical/statistics/click*', + ], robotsTxtOptions: { additionalSitemaps: [ diff --git a/package.json b/package.json index a014c58..531f6d8 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "build:dep": "cross-env ANALYZE=true next build", "start": "next start", "server_start": "pm2 start ecosystem.config.js", - "server_reload": "next-sitemap --config next-sitemap.config.js && next build && pm2 reload ecosystem.config.js", + "server_reload": "next build && next-sitemap --config next-sitemap.config.js && pm2 reload ecosystem.config.js", "server_stop": "pm2 stop ecosystem.config.js", "lint": "next lint", "lint:fix": "eslint src --fix && yarn format", diff --git a/server.js b/server.js index 9a68149..32bc098 100644 --- a/server.js +++ b/server.js @@ -38,14 +38,16 @@ const handleRedirect = (req, res, locale, urlLocale) => { } if (locale === DEFAULT_LOCALE) { const newUrl = req.url.replace(`/${DEFAULT_LOCALE}`, '') || '/'; - return res.redirect(307, newUrl); + res.redirect(307, newUrl); + return true; } } else if (locale !== DEFAULT_LOCALE) { let newUrl = `/${locale}${req.url}`; if (newUrl.endsWith('/') && newUrl.length > 1) { newUrl = newUrl.slice(0, -1); } - return res.redirect(307, newUrl); + res.redirect(307, newUrl); + return true; } return false; }; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 1870925..4c25c54 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -14,14 +14,18 @@ import IndexBar from '@/components/navbar/IndexBar'; import Seo from '@/components/Seo'; import ToTop from '@/components/toTop/ToTop'; +const validSortBy = ['featured', 'all']; + const Index: NextPage = () => { const { t, i18n } = useTranslation('home'); const router = useRouter(); - const { sort_by = 'featured', tid = '' } = router.query; + const { sort_by = 'featured', tid = '' }: { sort_by?: string; tid?: string } = + router.query; + const sortBy = validSortBy.includes(sort_by) ? sort_by : 'featured'; const { isLogin } = useLoginContext(); const { repositories, isValidating, hasMore, size, sentryRef } = - useRepositories(sort_by as string, tid as string); + useRepositories(sortBy, tid); const handleItemBottom = () => { if (!isValidating && !hasMore) { @@ -37,12 +41,7 @@ const Index: NextPage = () => { return ( <> - +