@tanstack/create 0.61.5 → 0.61.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/frameworks/react/add-ons/strapi/README.md +158 -8
  3. package/dist/frameworks/react/add-ons/strapi/assets/_dot_env.local.append +1 -1
  4. package/dist/frameworks/react/add-ons/strapi/assets/src/components/blocks/block-renderer.tsx +55 -0
  5. package/dist/frameworks/react/add-ons/strapi/assets/src/components/blocks/index.ts +14 -0
  6. package/dist/frameworks/react/add-ons/strapi/assets/src/components/blocks/media.tsx +27 -0
  7. package/dist/frameworks/react/add-ons/strapi/assets/src/components/blocks/quote.tsx +19 -0
  8. package/dist/frameworks/react/add-ons/strapi/assets/src/components/blocks/rich-text.tsx +11 -0
  9. package/dist/frameworks/react/add-ons/strapi/assets/src/components/blocks/slider.tsx +28 -0
  10. package/dist/frameworks/react/add-ons/strapi/assets/src/components/markdown-content.tsx +74 -0
  11. package/dist/frameworks/react/add-ons/strapi/assets/src/components/pagination.tsx +120 -0
  12. package/dist/frameworks/react/add-ons/strapi/assets/src/components/search.tsx +35 -0
  13. package/dist/frameworks/react/add-ons/strapi/assets/src/components/strapi-image.tsx +47 -0
  14. package/dist/frameworks/react/add-ons/strapi/assets/src/data/loaders/articles.ts +106 -0
  15. package/dist/frameworks/react/add-ons/strapi/assets/src/data/loaders/index.ts +28 -0
  16. package/dist/frameworks/react/add-ons/strapi/assets/src/data/strapi-sdk.ts +9 -0
  17. package/dist/frameworks/react/add-ons/strapi/assets/src/lib/strapi-utils.ts +25 -0
  18. package/dist/frameworks/react/add-ons/strapi/assets/src/routes/demo/strapi.$articleId.tsx +170 -0
  19. package/dist/frameworks/react/add-ons/strapi/assets/src/routes/demo/strapi.tsx +269 -43
  20. package/dist/frameworks/react/add-ons/strapi/assets/src/types/strapi.ts +90 -0
  21. package/dist/frameworks/react/add-ons/strapi/info.json +3 -3
  22. package/dist/frameworks/react/add-ons/strapi/package.json +5 -2
  23. package/package.json +1 -1
  24. package/src/frameworks/react/add-ons/strapi/README.md +158 -8
  25. package/src/frameworks/react/add-ons/strapi/assets/_dot_env.local.append +1 -1
  26. package/src/frameworks/react/add-ons/strapi/assets/src/components/blocks/block-renderer.tsx +55 -0
  27. package/src/frameworks/react/add-ons/strapi/assets/src/components/blocks/index.ts +14 -0
  28. package/src/frameworks/react/add-ons/strapi/assets/src/components/blocks/media.tsx +27 -0
  29. package/src/frameworks/react/add-ons/strapi/assets/src/components/blocks/quote.tsx +19 -0
  30. package/src/frameworks/react/add-ons/strapi/assets/src/components/blocks/rich-text.tsx +11 -0
  31. package/src/frameworks/react/add-ons/strapi/assets/src/components/blocks/slider.tsx +28 -0
  32. package/src/frameworks/react/add-ons/strapi/assets/src/components/markdown-content.tsx +74 -0
  33. package/src/frameworks/react/add-ons/strapi/assets/src/components/pagination.tsx +120 -0
  34. package/src/frameworks/react/add-ons/strapi/assets/src/components/search.tsx +35 -0
  35. package/src/frameworks/react/add-ons/strapi/assets/src/components/strapi-image.tsx +47 -0
  36. package/src/frameworks/react/add-ons/strapi/assets/src/data/loaders/articles.ts +106 -0
  37. package/src/frameworks/react/add-ons/strapi/assets/src/data/loaders/index.ts +28 -0
  38. package/src/frameworks/react/add-ons/strapi/assets/src/data/strapi-sdk.ts +9 -0
  39. package/src/frameworks/react/add-ons/strapi/assets/src/lib/strapi-utils.ts +25 -0
  40. package/src/frameworks/react/add-ons/strapi/assets/src/routes/demo/strapi.$articleId.tsx +170 -0
  41. package/src/frameworks/react/add-ons/strapi/assets/src/routes/demo/strapi.tsx +269 -43
  42. package/src/frameworks/react/add-ons/strapi/assets/src/types/strapi.ts +90 -0
  43. package/src/frameworks/react/add-ons/strapi/info.json +3 -3
  44. package/src/frameworks/react/add-ons/strapi/package.json +5 -2
  45. package/dist/frameworks/react/add-ons/strapi/assets/src/lib/strapiClient.ts +0 -7
  46. package/dist/frameworks/react/add-ons/strapi/assets/src/routes/demo/strapi_.$articleId.tsx +0 -78
  47. package/src/frameworks/react/add-ons/strapi/assets/src/lib/strapiClient.ts +0 -7
  48. package/src/frameworks/react/add-ons/strapi/assets/src/routes/demo/strapi_.$articleId.tsx +0 -78
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @tanstack/create
2
2
 
3
+ ## 0.61.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Improve the Strapi add-on scaffolding for reliability. ([#323](https://github.com/TanStack/cli/pull/323))
8
+
9
+ - Remove brittle post-create shell automation that attempted to clone and bootstrap a sibling Strapi server.
10
+ - Fix Strapi article detail routing to use a consistent file-based route path.
11
+ - Update Strapi add-on guidance to document manual/hosted Strapi setup expectations.
12
+
3
13
  ## 0.61.5
4
14
 
5
15
  ### Patch Changes
@@ -1,14 +1,164 @@
1
- ## Setting up Strapi
1
+ ## Strapi CMS Integration
2
2
 
3
- The current setup shows an example of how to use Strapi with an articles collection which is part of the example structure & data.
3
+ This add-on integrates Strapi CMS with your TanStack Start application using the official Strapi Client SDK.
4
4
 
5
- - Create a local running copy of the strapi admin
5
+ ### Features
6
6
 
7
+ - Article listing with search and pagination
8
+ - Article detail pages with dynamic block rendering
9
+ - Rich text, quotes, media, and image slider blocks
10
+ - Markdown content rendering with GitHub Flavored Markdown
11
+ - Responsive image handling with error fallbacks
12
+ - URL-based search and pagination (shareable/bookmarkable)
13
+ - Graceful error handling with helpful setup instructions
14
+
15
+ ### Project Structure
16
+
17
+ ```
18
+ parent/
19
+ ├── client/ # TanStack Start frontend (your project name)
20
+ │ ├── src/
21
+ │ │ ├── components/
22
+ │ │ │ ├── blocks/ # Block rendering components
23
+ │ │ │ ├── markdown-content.tsx
24
+ │ │ │ ├── pagination.tsx
25
+ │ │ │ ├── search.tsx
26
+ │ │ │ └── strapi-image.tsx
27
+ │ │ ├── data/
28
+ │ │ │ ├── loaders/ # Server functions
29
+ │ │ │ └── strapi-sdk.ts
30
+ │ │ ├── lib/
31
+ │ │ │ └── strapi-utils.ts
32
+ │ │ ├── routes/demo/
33
+ │ │ │ ├── strapi.tsx # Articles list
34
+ │ │ │ └── strapi.$articleId.tsx # Article detail
35
+ │ │ └── types/
36
+ │ │ └── strapi.ts
37
+ │ ├── .env.local
38
+ │ └── package.json
39
+ └── server/ # Strapi CMS backend (create manually or use hosted Strapi)
40
+ ├── src/api/ # Content types
41
+ ├── config/ # Strapi configuration
42
+ └── package.json
43
+ ```
44
+
45
+ ### Quick Start
46
+
47
+ Create your Strapi project separately (or use an existing hosted Strapi instance), then point this app to it with `VITE_STRAPI_URL`.
48
+
49
+ **1. Set up Strapi:**
50
+
51
+ Follow the Strapi quick-start guide to create a local project, or use your existing Strapi deployment:
52
+
53
+ - https://docs.strapi.io/dev-docs/quick-start
54
+
55
+ If you created a local Strapi project in a sibling `server` directory, continue with:
56
+
57
+ ```bash
58
+ cd ../server
59
+ npm install # or pnpm install / yarn install
60
+ ```
61
+
62
+ **2. Start the Strapi server:**
63
+
64
+ ```bash
65
+ npm run develop # Starts at http://localhost:1337
66
+ ```
67
+
68
+ **3. Create an admin account:**
69
+
70
+ Open http://localhost:1337/admin and create your first admin user.
71
+
72
+ **4. Create content:**
73
+
74
+ In the Strapi admin panel, go to Content Manager > Article and create some articles.
75
+
76
+ **5. Start your TanStack app (in another terminal):**
77
+
78
+ ```bash
79
+ cd ../client # or your project name
80
+ npm run dev # Starts at http://localhost:3000
81
+ ```
82
+
83
+ **6. View the demo:**
84
+
85
+ Navigate to http://localhost:3000/demo/strapi to see your articles.
86
+
87
+ ### Environment Variables
88
+
89
+ The following environment variable is pre-configured in `.env.local`:
90
+
91
+ ```bash
92
+ VITE_STRAPI_URL="http://localhost:1337"
93
+ ```
94
+
95
+ For production, update this to your deployed Strapi URL.
96
+
97
+ ### Demo Pages
98
+
99
+ | URL | Description |
100
+ |-----|-------------|
101
+ | `/demo/strapi` | Articles list with search and pagination |
102
+ | `/demo/strapi/:articleId` | Article detail with block rendering |
103
+
104
+ ### Search and Pagination
105
+
106
+ - **Search**: Type in the search box to filter articles by title or description
107
+ - **Pagination**: Navigate between pages using the pagination controls
108
+ - **URL State**: Search and page are stored in the URL (`?query=term&page=2`)
109
+
110
+ ### Block Types Supported
111
+
112
+ | Block | Component | Description |
113
+ |-------|-----------|-------------|
114
+ | `shared.rich-text` | RichText | Markdown content |
115
+ | `shared.quote` | Quote | Blockquote with author |
116
+ | `shared.media` | Media | Single image/video |
117
+ | `shared.slider` | Slider | Image gallery grid |
118
+
119
+ ### Dependencies
120
+
121
+ | Package | Purpose |
122
+ |---------|---------|
123
+ | `@strapi/client` | Official Strapi SDK |
124
+ | `react-markdown` | Markdown rendering |
125
+ | `remark-gfm` | GitHub Flavored Markdown |
126
+ | `use-debounce` | Debounced search input |
127
+
128
+ ### Running Both Servers
129
+
130
+ Open two terminal windows from the parent directory:
131
+
132
+ **Terminal 1 - Strapi:**
7
133
  ```bash
8
- pnpm dlx create-strapi@latest my-strapi-project
9
- cd my-strapi-project
10
- pnpm dev
134
+ cd server && npm run develop
11
135
  ```
12
136
 
13
- - Login and publish the example articles to see them on the strapi demo page.
14
- - Set the `VITE_STRAPI_URL` environment variable in your `.env.local`. (For local it should be http://localhost:1337/api)
137
+ **Terminal 2 - TanStack Start:**
138
+ ```bash
139
+ cd client && npm run dev # or your project name
140
+ ```
141
+
142
+ ### Customization
143
+
144
+ **Change page size:**
145
+ Edit `src/data/loaders/articles.ts` and modify `PAGE_SIZE`.
146
+
147
+ **Add new block types:**
148
+ 1. Create component in `src/components/blocks/`
149
+ 2. Export from `src/components/blocks/index.ts`
150
+ 3. Add case to `block-renderer.tsx` switch statement
151
+ 4. Update populate in articles loader
152
+
153
+ **Add new content types:**
154
+ 1. Add types to `src/types/strapi.ts`
155
+ 2. Create loader in `src/data/loaders/`
156
+ 3. Create route in `src/routes/demo/`
157
+
158
+ ### Learn More
159
+
160
+ - [Strapi Documentation](https://docs.strapi.io/)
161
+ - [Strapi Client SDK](https://www.npmjs.com/package/@strapi/client)
162
+ - [Strapi Cloud Template Blog](https://github.com/strapi/strapi-cloud-template-blog)
163
+ - [TanStack Start Documentation](https://tanstack.com/start/latest)
164
+ - [TanStack Router Search Params](https://tanstack.com/router/latest/docs/framework/react/guide/search-params)
@@ -1,2 +1,2 @@
1
1
  # Strapi configuration
2
- VITE_STRAPI_URL="http://localhost:1337/api"
2
+ VITE_STRAPI_URL="http://localhost:1337"
@@ -0,0 +1,55 @@
1
+ import { RichText } from "./rich-text";
2
+ import { Quote } from "./quote";
3
+ import { Media } from "./media";
4
+ import { Slider } from "./slider";
5
+
6
+ import type { IRichText } from "./rich-text";
7
+ import type { IQuote } from "./quote";
8
+ import type { IMedia } from "./media";
9
+ import type { ISlider } from "./slider";
10
+
11
+ // Union type of all block types
12
+ export type Block = IRichText | IQuote | IMedia | ISlider;
13
+
14
+ interface BlockRendererProps {
15
+ blocks: Array<Block>;
16
+ }
17
+
18
+ /**
19
+ * BlockRenderer - Renders dynamic content blocks from Strapi
20
+ *
21
+ * Usage:
22
+ * ```tsx
23
+ * <BlockRenderer blocks={article.blocks} />
24
+ * ```
25
+ */
26
+ export function BlockRenderer({ blocks }: Readonly<BlockRendererProps>) {
27
+ if (!blocks || blocks.length === 0) return null;
28
+
29
+ const renderBlock = (block: Block) => {
30
+ switch (block.__component) {
31
+ case "shared.rich-text":
32
+ return <RichText {...block} />;
33
+ case "shared.quote":
34
+ return <Quote {...block} />;
35
+ case "shared.media":
36
+ return <Media {...block} />;
37
+ case "shared.slider":
38
+ return <Slider {...block} />;
39
+ default:
40
+ // Log unknown block types in development
41
+ console.warn("Unknown block type:", (block as any).__component);
42
+ return null;
43
+ }
44
+ };
45
+
46
+ return (
47
+ <div className="space-y-6">
48
+ {blocks.map((block, index) => (
49
+ <div key={`${block.__component}-${block.id}-${index}`}>
50
+ {renderBlock(block)}
51
+ </div>
52
+ ))}
53
+ </div>
54
+ );
55
+ }
@@ -0,0 +1,14 @@
1
+ export { BlockRenderer } from "./block-renderer";
2
+ export type { Block } from "./block-renderer";
3
+
4
+ export { RichText } from "./rich-text";
5
+ export type { IRichText } from "./rich-text";
6
+
7
+ export { Quote } from "./quote";
8
+ export type { IQuote } from "./quote";
9
+
10
+ export { Media } from "./media";
11
+ export type { IMedia } from "./media";
12
+
13
+ export { Slider } from "./slider";
14
+ export type { ISlider } from "./slider";
@@ -0,0 +1,27 @@
1
+ import { StrapiImage } from "@/components/strapi-image";
2
+ import type { TImage } from "@/types/strapi";
3
+
4
+ export interface IMedia {
5
+ __component: "shared.media";
6
+ id: number;
7
+ file?: TImage;
8
+ }
9
+
10
+ export function Media({ file }: Readonly<IMedia>) {
11
+ if (!file) return null;
12
+
13
+ return (
14
+ <figure className="my-8">
15
+ <StrapiImage
16
+ src={file.url}
17
+ alt={file.alternativeText || ""}
18
+ className="rounded-lg w-full"
19
+ />
20
+ {file.alternativeText && (
21
+ <figcaption className="mt-2 text-center text-sm text-gray-500">
22
+ {file.alternativeText}
23
+ </figcaption>
24
+ )}
25
+ </figure>
26
+ );
27
+ }
@@ -0,0 +1,19 @@
1
+ export interface IQuote {
2
+ __component: "shared.quote";
3
+ id: number;
4
+ body: string;
5
+ title?: string;
6
+ }
7
+
8
+ export function Quote({ body, title }: Readonly<IQuote>) {
9
+ return (
10
+ <blockquote className="border-l-4 border-cyan-400 pl-6 py-4 my-6 bg-slate-800/30 rounded-r-lg">
11
+ <p className="text-xl italic text-gray-300 leading-relaxed">{body}</p>
12
+ {title && (
13
+ <cite className="block mt-4 text-cyan-400 not-italic font-medium">
14
+ — {title}
15
+ </cite>
16
+ )}
17
+ </blockquote>
18
+ );
19
+ }
@@ -0,0 +1,11 @@
1
+ import { MarkdownContent } from "@/components/markdown-content";
2
+
3
+ export interface IRichText {
4
+ __component: "shared.rich-text";
5
+ id: number;
6
+ body: string;
7
+ }
8
+
9
+ export function RichText({ body }: Readonly<IRichText>) {
10
+ return <MarkdownContent content={body} />;
11
+ }
@@ -0,0 +1,28 @@
1
+ import { StrapiImage } from "@/components/strapi-image";
2
+ import type { TImage } from "@/types/strapi";
3
+
4
+ export interface ISlider {
5
+ __component: "shared.slider";
6
+ id: number;
7
+ files?: Array<TImage>;
8
+ }
9
+
10
+ export function Slider({ files }: Readonly<ISlider>) {
11
+ if (!files || files.length === 0) return null;
12
+
13
+ return (
14
+ <div className="my-8">
15
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
16
+ {files.map((file, index) => (
17
+ <figure key={file.id || index}>
18
+ <StrapiImage
19
+ src={file.url}
20
+ alt={file.alternativeText || ""}
21
+ className="rounded-lg w-full h-48 object-cover"
22
+ />
23
+ </figure>
24
+ ))}
25
+ </div>
26
+ </div>
27
+ );
28
+ }
@@ -0,0 +1,74 @@
1
+ import Markdown from "react-markdown";
2
+ import remarkGfm from "remark-gfm";
3
+
4
+ interface MarkdownContentProps {
5
+ content: string | undefined | null;
6
+ className?: string;
7
+ }
8
+
9
+ const styles = {
10
+ h1: "text-3xl font-bold mb-6 text-white",
11
+ h2: "text-2xl font-bold mb-4 text-white",
12
+ h3: "text-xl font-bold mb-3 text-white",
13
+ p: "mb-4 leading-relaxed text-gray-300",
14
+ a: "text-cyan-400 hover:underline",
15
+ ul: "list-disc pl-6 mb-4 space-y-2 text-gray-300",
16
+ ol: "list-decimal pl-6 mb-4 space-y-2 text-gray-300",
17
+ li: "leading-relaxed",
18
+ blockquote: "border-l-4 border-cyan-400 pl-4 italic text-gray-400 my-4",
19
+ code: "bg-slate-800 px-2 py-1 rounded text-cyan-400 text-sm font-mono",
20
+ pre: "bg-slate-800 p-4 rounded-lg overflow-x-auto mb-4",
21
+ table: "w-full border-collapse mb-4",
22
+ th: "border border-slate-700 p-2 bg-slate-800 text-left text-white",
23
+ td: "border border-slate-700 p-2 text-gray-300",
24
+ img: "max-w-full h-auto rounded-lg my-4",
25
+ hr: "border-slate-700 my-8",
26
+ strong: "text-white font-semibold",
27
+ };
28
+
29
+ export function MarkdownContent({ content, className = "" }: MarkdownContentProps) {
30
+ if (!content) return null;
31
+
32
+ return (
33
+ <div className={`prose prose-invert max-w-none ${className}`}>
34
+ <Markdown
35
+ remarkPlugins={[remarkGfm]}
36
+ components={{
37
+ h1: ({ children }) => <h1 className={styles.h1}>{children}</h1>,
38
+ h2: ({ children }) => <h2 className={styles.h2}>{children}</h2>,
39
+ h3: ({ children }) => <h3 className={styles.h3}>{children}</h3>,
40
+ p: ({ children }) => <p className={styles.p}>{children}</p>,
41
+ a: ({ href, children }) => (
42
+ <a href={href} className={styles.a} target="_blank" rel="noopener noreferrer">
43
+ {children}
44
+ </a>
45
+ ),
46
+ ul: ({ children }) => <ul className={styles.ul}>{children}</ul>,
47
+ ol: ({ children }) => <ol className={styles.ol}>{children}</ol>,
48
+ li: ({ children }) => <li className={styles.li}>{children}</li>,
49
+ blockquote: ({ children }) => <blockquote className={styles.blockquote}>{children}</blockquote>,
50
+ code: ({ className, children }) => {
51
+ const isCodeBlock = className?.includes("language-");
52
+ if (isCodeBlock) {
53
+ return (
54
+ <pre className={styles.pre}>
55
+ <code className="text-sm font-mono text-gray-300">{children}</code>
56
+ </pre>
57
+ );
58
+ }
59
+ return <code className={styles.code}>{children}</code>;
60
+ },
61
+ pre: ({ children }) => <>{children}</>,
62
+ table: ({ children }) => <table className={styles.table}>{children}</table>,
63
+ th: ({ children }) => <th className={styles.th}>{children}</th>,
64
+ td: ({ children }) => <td className={styles.td}>{children}</td>,
65
+ img: ({ src, alt }) => <img src={src} alt={alt || ""} className={styles.img} />,
66
+ hr: () => <hr className={styles.hr} />,
67
+ strong: ({ children }) => <strong className={styles.strong}>{children}</strong>,
68
+ }}
69
+ >
70
+ {content}
71
+ </Markdown>
72
+ </div>
73
+ );
74
+ }
@@ -0,0 +1,120 @@
1
+ import { useRouter, useSearch } from '@tanstack/react-router'
2
+ import { ChevronLeft, ChevronRight } from 'lucide-react'
3
+
4
+ interface PaginationProps {
5
+ pageCount: number
6
+ className?: string
7
+ }
8
+
9
+ export function Pagination({ pageCount, className = '' }: PaginationProps) {
10
+ const router = useRouter()
11
+ const search = useSearch({ strict: false })
12
+ const currentPage = Number((search as any)?.page) || 1
13
+
14
+ const handlePageChange = (page: number) => {
15
+ router.navigate({
16
+ to: '.',
17
+ search: (prev) => ({ ...prev, page }),
18
+ replace: true,
19
+ })
20
+ }
21
+
22
+ // Generate page numbers to display
23
+ const getPageNumbers = () => {
24
+ const pages: Array<number | 'ellipsis'> = []
25
+ const showEllipsis = pageCount > 7
26
+
27
+ if (showEllipsis) {
28
+ pages.push(1)
29
+
30
+ if (currentPage > 3) {
31
+ pages.push('ellipsis')
32
+ }
33
+
34
+ const start = Math.max(2, currentPage - 1)
35
+ const end = Math.min(pageCount - 1, currentPage + 1)
36
+
37
+ for (let i = start; i <= end; i++) {
38
+ pages.push(i)
39
+ }
40
+
41
+ if (currentPage < pageCount - 2) {
42
+ pages.push('ellipsis')
43
+ }
44
+
45
+ if (pageCount > 1) {
46
+ pages.push(pageCount)
47
+ }
48
+ } else {
49
+ for (let i = 1; i <= pageCount; i++) {
50
+ pages.push(i)
51
+ }
52
+ }
53
+
54
+ return pages
55
+ }
56
+
57
+ const pageNumbers = getPageNumbers()
58
+
59
+ if (pageCount <= 1) return null
60
+
61
+ return (
62
+ <nav className={`flex items-center justify-center gap-1 ${className}`}>
63
+ {/* Previous Button */}
64
+ <button
65
+ onClick={() => currentPage > 1 && handlePageChange(currentPage - 1)}
66
+ disabled={currentPage <= 1}
67
+ className={`flex items-center gap-1 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${
68
+ currentPage <= 1
69
+ ? 'text-gray-600 cursor-not-allowed'
70
+ : 'text-gray-300 hover:bg-slate-700 hover:text-white'
71
+ }`}
72
+ >
73
+ <ChevronLeft className="w-4 h-4" />
74
+ <span className="hidden sm:inline">Previous</span>
75
+ </button>
76
+
77
+ {/* Page Numbers */}
78
+ <div className="flex items-center gap-1">
79
+ {pageNumbers.map((page, index) =>
80
+ page === 'ellipsis' ? (
81
+ <span
82
+ key={`ellipsis-${index}`}
83
+ className="px-2 py-2 text-gray-500 hidden md:block"
84
+ >
85
+ ...
86
+ </span>
87
+ ) : (
88
+ <button
89
+ key={page}
90
+ onClick={() => handlePageChange(page)}
91
+ className={`min-w-[40px] px-3 py-2 rounded-lg text-sm font-medium transition-colors ${
92
+ currentPage === page
93
+ ? 'bg-cyan-500 text-white'
94
+ : 'text-gray-300 hover:bg-slate-700 hover:text-white'
95
+ }`}
96
+ >
97
+ {page}
98
+ </button>
99
+ )
100
+ )}
101
+ </div>
102
+
103
+ {/* Next Button */}
104
+ <button
105
+ onClick={() =>
106
+ currentPage < pageCount && handlePageChange(currentPage + 1)
107
+ }
108
+ disabled={currentPage >= pageCount}
109
+ className={`flex items-center gap-1 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${
110
+ currentPage >= pageCount
111
+ ? 'text-gray-600 cursor-not-allowed'
112
+ : 'text-gray-300 hover:bg-slate-700 hover:text-white'
113
+ }`}
114
+ >
115
+ <span className="hidden sm:inline">Next</span>
116
+ <ChevronRight className="w-4 h-4" />
117
+ </button>
118
+ </nav>
119
+ )
120
+ }
@@ -0,0 +1,35 @@
1
+ import { useRouter, useSearch } from "@tanstack/react-router";
2
+ import { useDebouncedCallback } from "use-debounce";
3
+
4
+ interface SearchProps {
5
+ readonly className?: string;
6
+ }
7
+
8
+ export function Search({ className = "" }: SearchProps) {
9
+ const search = useSearch({ strict: false });
10
+ const router = useRouter();
11
+
12
+ const handleSearch = useDebouncedCallback((term: string) => {
13
+ router.navigate({
14
+ to: ".",
15
+ search: (prev) => ({
16
+ ...prev,
17
+ page: 1,
18
+ query: term || undefined,
19
+ }),
20
+ replace: true,
21
+ });
22
+ }, 300);
23
+
24
+ return (
25
+ <input
26
+ type="text"
27
+ placeholder="Search articles..."
28
+ onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
29
+ handleSearch(e.target.value)
30
+ }
31
+ defaultValue={(search as any)?.query || ""}
32
+ className={`w-full px-4 py-3 bg-slate-800 border border-slate-700 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:border-cyan-500 focus:ring-1 focus:ring-cyan-500 transition-colors ${className}`}
33
+ />
34
+ );
35
+ }
@@ -0,0 +1,47 @@
1
+ import { useState } from "react";
2
+ import { getStrapiMedia } from "@/lib/strapi-utils";
3
+
4
+ interface StrapiImageProps {
5
+ src: string | undefined | null;
6
+ alt?: string | null;
7
+ className?: string;
8
+ width?: number | string;
9
+ height?: number | string;
10
+ }
11
+
12
+ export function StrapiImage({
13
+ src,
14
+ alt,
15
+ className = "",
16
+ width,
17
+ height,
18
+ }: StrapiImageProps) {
19
+ const [hasError, setHasError] = useState(false);
20
+
21
+ if (!src) return null;
22
+
23
+ const imageUrl = getStrapiMedia(src);
24
+
25
+ if (hasError) {
26
+ return (
27
+ <div
28
+ className={`bg-slate-700 flex items-center justify-center text-slate-400 text-sm ${className}`}
29
+ style={{ width, height }}
30
+ >
31
+ <span>Image not available</span>
32
+ </div>
33
+ );
34
+ }
35
+
36
+ return (
37
+ <img
38
+ src={imageUrl}
39
+ alt={alt || ""}
40
+ width={width}
41
+ height={height}
42
+ loading="lazy"
43
+ className={`object-cover ${className}`}
44
+ onError={() => setHasError(true)}
45
+ />
46
+ );
47
+ }