Skip to content

Commit 7b32e82

Browse files
authored
Merge pull request #96 from techdiary-dev/kingrayhan/fix
Kingrayhan/fix
2 parents 32ac0eb + 9f821b6 commit 7b32e82

12 files changed

Lines changed: 281 additions & 156 deletions

File tree

AGENTS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
@CLAUDE.md
2+
3+
<!-- BEGIN:nextjs-agent-rules -->
4+
5+
# Next.js: ALWAYS read docs before coding
6+
7+
Before any Next.js work, find and read the relevant doc in `node_modules/next/dist/docs/`. Your training data is outdated — the docs are the source of truth.
8+
9+
<!-- END:nextjs-agent-rules -->

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ This project adheres to [Semantic Versioning](https://semver.org/).
66

77
---
88

9+
## v1.7.0 — 2026-04-02
10+
11+
### ✨ Features
12+
- feat: enhance notification display with actor profile images (c3db2ac)
13+
- feat: update documentation and agent rules for Next.js and file storage strategy (3ef4213)
14+
15+
### 🐛 Bug Fixes
16+
- fix: update profile photo handling in notifications (2d4f4be)
17+
18+
### 🔧 Other Changes
19+
- refactor: simplify Notification model's actor property (1d94a84)
20+
- refactor: improve formatting and structure in comment section component (2744811)
21+
- refactor: streamline get_comments function definition (a3d0512)
22+
23+
---
24+
925
## v1.6.0 — 2026-04-01
1026

1127
### ✨ Features

CLAUDE.md

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,27 @@ Key entities and their relationships:
8787
### Content Management
8888

8989
- **Rich Text**: Markdoc for markdown parsing and rendering
90-
- **File Uploads**: Cloudinary integration for images/media
90+
- **File Uploads**: Cloudflare R2 (primary) + Cloudinary (legacy/image optimization)
9191
- **Search**: MeilSearch for full-text search capabilities
9292
- **Internationalization**: Custom i18n implementation (Bengali/English)
9393

94+
### File Storage Strategy
95+
96+
Two storage providers coexist. `getFileUrl(fileSource)` (`src/utils/getFileUrl.ts`) routes by `fileSource.provider`:
97+
98+
- **`r2`** → returns `https://cdn.techdiary.dev/${key}` directly (no transforms)
99+
- **`cloudinary`** → builds URL with auto quality/format via Cloudinary SDK (supports blur placeholders)
100+
101+
**Upload flow for R2**: Client calls `POST /api/storage/sign` with `{ keys: string[] }` → server generates presigned S3-compatible URLs → client uploads directly to R2.
102+
103+
### i18n Usage
104+
105+
Only Bengali (`bn`) has a dictionary (`src/i18n/bn.json`); English falls back to the raw key.
106+
107+
- **Server components / actions**: `import _t from "@/i18n/_t"``await _t("key")` (reads `language` cookie)
108+
- **Client components**: `const { _t, lang, toggle } = useTranslation()` from `@/i18n/use-translation` (reads Jotai `i18nLangAtom`)
109+
- `toggle()` switches lang in both the atom and the `language` cookie via `setLanguage` server action
110+
94111
### State Management Patterns
95112

96113
- **Server State**: TanStack Query for data fetching in components
@@ -118,6 +135,14 @@ Client-side:
118135
- `NEXT_PUBLIC_MEILISEARCH_API_HOST` - MeilSearch API host URL
119136
- `NEXT_PUBLIC_MEILISEARCH_SEARCH_API_KEY` - MeilSearch search API key
120137

138+
Cloudflare R2 (S3-compatible):
139+
140+
- `S3_ENDPOINT` - R2 endpoint URL
141+
- `S3_BUCKET` - R2 bucket name
142+
- `S3_ACCESS_KEY_ID` - R2 access key
143+
- `S3_SECRET_ACCESS_KEY` - R2 secret key
144+
- `CRON_SECRET` - Shared secret for `x-cron-secret` header on cron API endpoint
145+
121146
## Key Features Implementation
122147

123148
### Authentication Flow
@@ -336,7 +361,8 @@ const feedQuery = useInfiniteQuery({
336361
- **Bengali Language Support**: Custom font loading (Kohinoor Bangla) and i18n in `src/i18n/`
337362
- **SEO Optimization**: Dynamic sitemaps in `src/app/sitemaps/`, Open Graph tags, and schema markup
338363
- **No test framework**: There are no automated tests — use `bun run play` for backend experimentation
339-
- **Cloudflare Workers**: `wrangler.toml` is present; `bun run wrangler:dev` starts the worker locally
364+
- **Cloudflare Workers**: `wrangler.toml` configures a separate cron worker (`src/workers/cron-worker.ts`). `bun run wrangler:dev` starts it locally. The worker fires on `0 2 * * *` and calls `POST /api/cron/cleanup-articles` with `x-cron-secret` header.
365+
- **Article soft-delete**: Articles have a `delete_scheduled_at` field. Setting it schedules permanent deletion; `article-cleanup-service.ts` processes them when the cron fires. Use `restoreScheduleDeletedArticle` to cancel.
340366

341367
## Caching & ISR (Incremental Static Regeneration)
342368

@@ -358,14 +384,14 @@ export async function articleDetailByHandle(handle: string) {
358384

359385
**2. Set cache lifetime with `cacheLife()` (call inside the `'use cache'` function):**
360386

361-
| Profile | Stale | Revalidate | Use for |
362-
|---|---|---|---|
363-
| `"seconds"` | 0s | 1s | near-realtime |
364-
| `"minutes"` | 1min | 1min | frequently updated |
365-
| `"hours"` | 5min | 1hr | articles, profiles |
366-
| `"days"` | 1hr | 1day | tags, static content |
367-
| `"weeks"` | 1day | 1wk | rarely updated |
368-
| `"max"` | 30d | 30d | immutable content |
387+
| Profile | Stale | Revalidate | Use for |
388+
| ----------- | ----- | ---------- | -------------------- |
389+
| `"seconds"` | 0s | 1s | near-realtime |
390+
| `"minutes"` | 1min | 1min | frequently updated |
391+
| `"hours"` | 5min | 1hr | articles, profiles |
392+
| `"days"` | 1hr | 1day | tags, static content |
393+
| `"weeks"` | 1day | 1wk | rarely updated |
394+
| `"max"` | 30d | 30d | immutable content |
369395

370396
**3. Tag cache entries with `cacheTag()` and bust on mutation with `revalidateTag()`:**
371397

@@ -394,6 +420,10 @@ export async function updateMyArticle(input) {
394420
- Do NOT add `'use cache'` to functions that call `cookies()` or `headers()` — it will throw a build error
395421
- Do NOT add `'use cache'` to mutation actions (`createX`, `updateX`, `deleteX`)
396422

423+
<!-- BEGIN:nextjs-agent-rules -->
424+
397425
# Next.js: ALWAYS read docs before coding
398426

399427
Before any Next.js work, find and read the relevant doc in `node_modules/next/dist/docs/`. Your training data is outdated — the docs are the source of truth.
428+
429+
<!-- END:nextjs-agent-rules -->

src/backend/persistence/sql-functions/article_writers.view.sql renamed to migrations/sql-functions/article_writers.view.sql

File renamed without changes.

src/backend/persistence/sql-functions/get_comments.sql renamed to migrations/sql-functions/get_comments.sql

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,9 @@
55
-- Function: public.get_comments(p_resource_id uuid, p_resource_type character varying, p_parent_id uuid DEFAULT NULL::uuid, p_current_level integer DEFAULT 0)
66

77

8-
CREATE OR REPLACE FUNCTION public.get_comments(
9-
p_resource_id uuid,
10-
p_resource_type character varying,
11-
p_parent_id uuid DEFAULT NULL::uuid,
12-
p_current_level integer DEFAULT 0
13-
)
14-
RETURNS json
15-
LANGUAGE plpgsql
8+
CREATE OR REPLACE FUNCTION public.get_comments(p_resource_id uuid, p_resource_type character varying, p_parent_id uuid DEFAULT NULL::uuid, p_current_level integer DEFAULT 0)
9+
RETURNS json
10+
LANGUAGE plpgsql
1611
AS $function$
1712
DECLARE
1813
result JSON;
@@ -31,7 +26,8 @@ BEGIN
3126
'id', u.id,
3227
'name', u.name,
3328
'email', u.email,
34-
'username', u.username
29+
'username', u.username,
30+
'profile_photo', u.profile_photo
3531
),
3632
'replies', get_comments(p_resource_id, p_resource_type, c.id, 1)
3733
) ORDER BY c.created_at DESC -- Changed to DESC
@@ -58,7 +54,8 @@ BEGIN
5854
'id', u.id,
5955
'name', u.name,
6056
'email', u.email,
61-
'username', u.username
57+
'username', u.username,
58+
'profile_photo', u.profile_photo
6259
),
6360
'replies', get_comments(p_resource_id, p_resource_type, c.id, p_current_level + 1)
6461
) ORDER BY c.created_at DESC -- Changed to DESC
@@ -71,4 +68,4 @@ BEGIN
7168

7269
RETURN COALESCE(result, '[]'::json);
7370
END;
74-
$function$
71+
$function$

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "techdiary.dev-next",
3-
"version": "1.6.0",
3+
"version": "1.7.0",
44
"private": true,
55
"scripts": {
66
"dev": "next dev --turbo",

0 commit comments

Comments
 (0)