diff --git a/astro.config.mjs b/astro.config.mjs index 3a141d1..523a9fa 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -75,6 +75,7 @@ export default defineConfig({ }, vite: { + // @ts-expect-error - @tailwindcss/vite uses Vite 7.x types, Astro uses Vite 6.x plugins: [tailwindcss()], }, }); diff --git a/docs/cline/templates/astro-page.astro b/docs/cline/templates/astro-page.astro index 8a17fbb..0e5b488 100644 --- a/docs/cline/templates/astro-page.astro +++ b/docs/cline/templates/astro-page.astro @@ -30,13 +30,14 @@ export async function getStaticPaths() { const { lang } = Astro.props; // 页面元数据 -const pageTitle = '页面标题'; -const pageDescription = '页面描述'; +const siteTitle = '页面标题'; +// const pageDescription = '页面描述'; // 如需描述,可添加到 BaseLayout Props +const coverImageUrl = null; // 封面图片 URL,可为 URL | string | null --- - +
-

{pageTitle}

+

{siteTitle}

diff --git a/docs/cline/templates/unit-test.test.ts b/docs/cline/templates/unit-test.test.ts index d60c9be..2495264 100644 --- a/docs/cline/templates/unit-test.test.ts +++ b/docs/cline/templates/unit-test.test.ts @@ -121,7 +121,14 @@ describe('ModuleName', () => { // 辅助函数 (测试专用) // ============================================================ -function createMockPost(overrides = {}) { +/** + * 创建模拟文章数据 + * @example const post = _createMockPost({ title: 'Custom Title' }); + * + * 注意: 函数名以下划线开头表示这是模板示例函数, + * 使用时请根据需要重命名(去掉下划线) + */ +function _createMockPost(overrides = {}) { return { id: 'mock-id', title: 'Mock Post', @@ -132,3 +139,7 @@ function createMockPost(overrides = {}) { ...overrides, }; } + +// 示例用法 +const _mockPost = _createMockPost({ title: '自定义标题' }); +void _mockPost; // 防止未使用警告 diff --git a/src/api/utils/sanitize.ts b/src/api/utils/sanitize.ts index 0c63ebe..5d04dbd 100644 --- a/src/api/utils/sanitize.ts +++ b/src/api/utils/sanitize.ts @@ -185,7 +185,7 @@ function addSecurityToLinks(html: string): string { // 如果已有 rel 属性,确保包含 noopener noreferrer return match.replace( /rel="([^"]*)"/i, - (relMatch, relValue: string) => { + (_relMatch, relValue: string) => { const values = new Set(relValue.split(/\s+/)); values.add('noopener'); values.add('noreferrer'); diff --git a/src/components/posts/view/PostViewCarousel.tsx b/src/components/posts/view/PostViewCarousel.tsx index ba5a293..3fad902 100644 --- a/src/components/posts/view/PostViewCarousel.tsx +++ b/src/components/posts/view/PostViewCarousel.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { useRef, useState, useEffect, useCallback } from 'react'; import { motion, AnimatePresence } from 'motion/react'; import { ChevronLeft, ChevronRight } from 'lucide-react'; -import type { Post, PostTag } from '@api/ghost/types'; +import type { Post } from '@api/ghost/types'; import { PostType } from '@api/ghost/types'; import { Chip } from '@components/common/badge'; import { cn } from '@components/common/lib/utils'; diff --git a/src/components/posts/view/PostViewPagination.tsx b/src/components/posts/view/PostViewPagination.tsx index 9e1b7d9..96379b5 100644 --- a/src/components/posts/view/PostViewPagination.tsx +++ b/src/components/posts/view/PostViewPagination.tsx @@ -1,5 +1,4 @@ -import * as React from 'react'; -import { useCallback, useMemo } from 'react'; +import { useCallback } from 'react'; import { useAtomValue } from 'jotai'; import { cn } from '@components/common/lib/utils'; import { postViewAtom } from '@stores/postViewAtom'; @@ -100,7 +99,6 @@ export default function PostViewPagination({ const renderMarker = (index: number) => { const isCircle = isEndpoint(index); const isVisible = isIndexVisible(index); - const isActive = index === activeIndex; const dynamicWidth = getMarkerWidth(index); const baseClasses = cn( diff --git a/src/components/posts/view/PostViewScrollContainer.tsx b/src/components/posts/view/PostViewScrollContainer.tsx index 77921ba..e2dd3ad 100644 --- a/src/components/posts/view/PostViewScrollContainer.tsx +++ b/src/components/posts/view/PostViewScrollContainer.tsx @@ -50,17 +50,7 @@ export default function PostViewScrollContainer({ if (cards.length === 0) return; - const firstCard = cards[0] as HTMLElement; - const cardWidth = firstCard.getBoundingClientRect().width; - const containerWidth = container.clientWidth; - const { gap, peekRatio, initialVisibleCount } = LAYOUT_CONFIG; - - // 总宽度 = 左padding(gap) + 5*cardWidth + 4*gap + gap + 第6张15% - // containerWidth = gap + 5*cardWidth + 5*gap + cardWidth*peekRatio - // 由于卡片宽度已知,我们计算 padding = gap - // 实际需要的宽度 = gap + 5*cardWidth + 5*gap + cardWidth*peekRatio - // = 6*gap + 5*cardWidth + cardWidth*peekRatio - // = 6*gap + cardWidth*(5 + peekRatio) + const { gap } = LAYOUT_CONFIG; // 使用 gap 作为 padding const padding = gap; diff --git a/src/components/utils/GoogleAnalytics.astro b/src/components/utils/GoogleAnalytics.astro index 447da6c..9156671 100644 --- a/src/components/utils/GoogleAnalytics.astro +++ b/src/components/utils/GoogleAnalytics.astro @@ -23,10 +23,11 @@ if (import.meta.env.DEV && id && !isValidGAId) { enabled && ( <>