From 84236f3cffaa93b89e00f8acad1c655cc535893c Mon Sep 17 00:00:00 2001 From: LooseLi <1329307562@qq.com> Date: Tue, 27 May 2025 10:06:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20eslint=20=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugins/algolia.js | 2 +- lib/plugins/mailchimp.js | 16 ++++++++++------ lib/robots.txt.js | 2 +- lib/sitemap.xml.js | 2 +- middleware.ts | 2 +- next.config.js | 8 ++++---- pages/api/auth/callback/notion.ts | 5 ++++- pages/dashboard/[[...index]].js | 2 +- pages/search/[keyword]/index.js | 4 ++-- pages/search/[keyword]/page/[page].js | 4 ++-- pages/sign-in/[[...index]].js | 2 +- pages/sign-up/[[...index]].js | 2 +- 12 files changed, 29 insertions(+), 22 deletions(-) diff --git a/lib/plugins/algolia.js b/lib/plugins/algolia.js index d161bf58..e6c76422 100644 --- a/lib/plugins/algolia.js +++ b/lib/plugins/algolia.js @@ -6,7 +6,7 @@ import algoliasearch from 'algoliasearch' * 生成全文索引 * @param {*} allPages */ -const generateAlgoliaSearch = async ({ allPages, force = false }) => { +const generateAlgoliaSearch = ({ allPages, force = false }) => { allPages?.forEach(p => { // 判断这篇文章是否需要重新创建索引 if (p && !p.password) { diff --git a/lib/plugins/mailchimp.js b/lib/plugins/mailchimp.js index 1d8bd2e2..29171819 100644 --- a/lib/plugins/mailchimp.js +++ b/lib/plugins/mailchimp.js @@ -1,15 +1,19 @@ import BLOG from '@/blog.config' /** -* 订阅邮件-服务端接口 -* @param {*} email -* @returns -*/ -export default function subscribeToMailchimpApi({ email, first_name = '', last_name = '' }) { + * 订阅邮件-服务端接口 + * @param {*} email + * @returns + */ +export default function subscribeToMailchimpApi({ + email, + first_name = '', + last_name = '' +}) { const listId = BLOG.MAILCHIMP_LIST_ID // 替换为你的邮件列表 ID const apiKey = BLOG.MAILCHIMP_API_KEY // 替换为你的 API KEY if (!email || !listId || !apiKey) { - return {} + return Promise.resolve({}) } const data = { email_address: email, diff --git a/lib/robots.txt.js b/lib/robots.txt.js index 45e11606..63956845 100644 --- a/lib/robots.txt.js +++ b/lib/robots.txt.js @@ -1,6 +1,6 @@ import fs from 'fs' -export async function generateRobotsTxt(props) { +export function generateRobotsTxt(props) { const { siteInfo } = props const LINK = siteInfo?.link const content = ` diff --git a/lib/sitemap.xml.js b/lib/sitemap.xml.js index 1ff513f7..1c931a50 100644 --- a/lib/sitemap.xml.js +++ b/lib/sitemap.xml.js @@ -5,7 +5,7 @@ import { siteConfig } from './config' * 生成站点地图 * @param {*} param0 */ -export async function generateSitemapXml({ allPages, NOTION_CONFIG }) { +export function generateSitemapXml({ allPages, NOTION_CONFIG }) { let link = siteConfig('LINK', BLOG.LINK, NOTION_CONFIG) // 确保链接不以斜杠结尾 if (link && link.endsWith('/')) { diff --git a/middleware.ts b/middleware.ts index 550c6f8b..1906db68 100644 --- a/middleware.ts +++ b/middleware.ts @@ -64,7 +64,7 @@ const noAuthMiddleware = async (req: NextRequest, ev: any) => { * 鉴权中间件 */ const authMiddleware = process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY - ? clerkMiddleware(async (auth, req) => { + ? clerkMiddleware((auth, req) => { const { userId } = auth() // 处理 /dashboard 路由的登录保护 if (isTenantRoute(req)) { diff --git a/next.config.js b/next.config.js index 3b8d7135..1bba8d1c 100644 --- a/next.config.js +++ b/next.config.js @@ -117,7 +117,7 @@ const nextConfig = { // 默认将feed重定向至 /public/rss/feed.xml redirects: process.env.EXPORT ? undefined - : async () => { + : () => { return [ { source: '/feed', @@ -129,7 +129,7 @@ const nextConfig = { // 重写url rewrites: process.env.EXPORT ? undefined - : async () => { + : () => { // 处理多语言重定向 const langsRewrites = [] if (BLOG.NOTION_PAGE_ID.indexOf(',') > 0) { @@ -176,7 +176,7 @@ const nextConfig = { }, headers: process.env.EXPORT ? undefined - : async () => { + : () => { return [ { source: '/:path*{/}?', @@ -217,7 +217,7 @@ const nextConfig = { experimental: { scrollRestoration: true }, - exportPathMap: async function ( + exportPathMap: function ( defaultPathMap, { dev, dir, outDir, distDir, buildId } ) { diff --git a/pages/api/auth/callback/notion.ts b/pages/api/auth/callback/notion.ts index b69a1982..467577f1 100644 --- a/pages/api/auth/callback/notion.ts +++ b/pages/api/auth/callback/notion.ts @@ -62,7 +62,10 @@ export default async function handler( } // 这里将用户数据写入到Notion数据库 - res.redirect(302, `/auth/result?${new URLSearchParams(redirectQuery)}`) + res.redirect( + 302, + `/auth/result?${new URLSearchParams(redirectQuery).toString()}` + ) } else { const redirectQuery = { msg: params?.statusText || '请求异常' } res.redirect( diff --git a/pages/dashboard/[[...index]].js b/pages/dashboard/[[...index]].js index 790bd723..330625e3 100644 --- a/pages/dashboard/[[...index]].js +++ b/pages/dashboard/[[...index]].js @@ -71,7 +71,7 @@ export async function getStaticProps({ locale }) { } } -export const getStaticPaths = async () => { +export const getStaticPaths = () => { return { paths: [ { params: { index: [] } }, // 对应首页路径 diff --git a/pages/search/[keyword]/index.js b/pages/search/[keyword]/index.js index b62ef8a9..4116e689 100644 --- a/pages/search/[keyword]/index.js +++ b/pages/search/[keyword]/index.js @@ -51,7 +51,7 @@ export async function getStaticProps({ params: { keyword }, locale }) { } } -export async function getStaticPaths() { +export function getStaticPaths() { return { paths: [{ params: { keyword: 'NotionNext' } }], fallback: true @@ -128,7 +128,7 @@ async function filterByMemCache(allPosts, keyword) { // console.log('全文搜索缓存', cacheKey, page != null) post.results = [] let hitCount = 0 - for (const i in indexContent) { + for (const i of indexContent) { const c = indexContent[i] if (!c) { continue diff --git a/pages/search/[keyword]/page/[page].js b/pages/search/[keyword]/page/[page].js index e0d20acc..371d23e7 100644 --- a/pages/search/[keyword]/page/[page].js +++ b/pages/search/[keyword]/page/[page].js @@ -50,7 +50,7 @@ export async function getStaticProps({ params: { keyword, page }, locale }) { } } -export async function getStaticPaths() { +export function getStaticPaths() { return { paths: [{ params: { keyword: 'NotionNext', page: '1' } }], fallback: true @@ -135,7 +135,7 @@ async function filterByMemCache(allPosts, keyword) { // console.log('全文搜索缓存', cacheKey, page != null) post.results = [] let hitCount = 0 - for (const i in indexContent) { + for (const i of indexContent) { const c = indexContent[i] if (!c) { continue diff --git a/pages/sign-in/[[...index]].js b/pages/sign-in/[[...index]].js index 135ae292..f11964f1 100644 --- a/pages/sign-in/[[...index]].js +++ b/pages/sign-in/[[...index]].js @@ -37,7 +37,7 @@ export async function getStaticProps(req) { * catch-all route for clerk * @returns */ -export async function getStaticPaths() { +export function getStaticPaths() { return { paths: [ { params: { index: [] } }, // 使 /sign-in 路径可访问 diff --git a/pages/sign-up/[[...index]].js b/pages/sign-up/[[...index]].js index f721ec6f..d5120600 100644 --- a/pages/sign-up/[[...index]].js +++ b/pages/sign-up/[[...index]].js @@ -36,7 +36,7 @@ export async function getStaticProps(req) { * catch-all route for clerk * @returns */ -export async function getStaticPaths() { +export function getStaticPaths() { return { paths: [ { params: { index: [] } }, // 使 /sign-up 路径可访问