Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
},
});
9 changes: 5 additions & 4 deletions docs/cline/templates/astro-page.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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
---

<BaseLayout title={pageTitle} description={pageDescription} lang={lang}>
<BaseLayout siteTitle={siteTitle} coverImageUrl={coverImageUrl} locale={lang}>
<main class="container mx-auto px-4 py-8">
<h1 class="mb-6 text-3xl font-bold">{pageTitle}</h1>
<h1 class="mb-6 text-3xl font-bold">{siteTitle}</h1>

<!-- 页面内容 -->
<section>
Expand Down
13 changes: 12 additions & 1 deletion docs/cline/templates/unit-test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -132,3 +139,7 @@ function createMockPost(overrides = {}) {
...overrides,
};
}

// 示例用法
const _mockPost = _createMockPost({ title: '自定义标题' });
void _mockPost; // 防止未使用警告
2 changes: 1 addition & 1 deletion src/api/utils/sanitize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/components/posts/view/PostViewCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 1 addition & 3 deletions src/components/posts/view/PostViewPagination.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(
Expand Down
12 changes: 1 addition & 11 deletions src/components/posts/view/PostViewScrollContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/components/utils/GoogleAnalytics.astro
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ if (import.meta.env.DEV && id && !isValidGAId) {
enabled && (
<>
<script
is:inline
async
src={`https://www.googletagmanager.com/gtag/js?id=${id}`}
/>
<script define:vars={{ id }}>
<script is:inline define:vars={{ id }}>
window.dataLayer = window.dataLayer || []; function gtag()
{dataLayer.push(arguments)}
gtag('js', new Date()); gtag('config', id);
Expand Down