57 lines
1.8 KiB
Markdown
57 lines
1.8 KiB
Markdown
|
|
# Posts title fields for list/card surfaces
|
|||
|
|
|
|||
|
|
Front-end list/card surfaces such as **热门资料**, **官方推荐**, and **全部资料** should display a short title, not the full Telegram/body text.
|
|||
|
|
|
|||
|
|
## Affected endpoints
|
|||
|
|
|
|||
|
|
Any endpoint returning `Post` items should include a short title when available:
|
|||
|
|
|
|||
|
|
- `GET /api/posts`
|
|||
|
|
- `GET /api/posts/search`
|
|||
|
|
- `GET /api/posts/recommended`
|
|||
|
|
- `GET /api/posts/:id`
|
|||
|
|
|
|||
|
|
## Recommended response shape
|
|||
|
|
|
|||
|
|
```jsonc
|
|||
|
|
{
|
|||
|
|
"id": "string",
|
|||
|
|
"title": "ARK 2026 共识加速计划", // optional global fallback title
|
|||
|
|
"text": "完整正文 / Telegram-style body text...",
|
|||
|
|
"localizations": {
|
|||
|
|
"zh": {
|
|||
|
|
"title": "ARK 2026 共识加速计划",
|
|||
|
|
"text": "完整中文正文...",
|
|||
|
|
},
|
|||
|
|
"en": {
|
|||
|
|
"title": "ARK 2026 Consensus Acceleration Plan",
|
|||
|
|
"text": "Full English body...",
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## Front-end fallback order
|
|||
|
|
|
|||
|
|
For `Resource.title`, front-end reads:
|
|||
|
|
|
|||
|
|
1. `localizations[currentLang].title`
|
|||
|
|
2. `post.title`
|
|||
|
|
3. first non-empty line of localized/full `text`
|
|||
|
|
4. first attachment filename
|
|||
|
|
5. `post.id`
|
|||
|
|
|
|||
|
|
So backend can roll this out gradually: old posts without `title` still render, but long body text will be reduced to its first line.
|
|||
|
|
|
|||
|
|
## Requirement
|
|||
|
|
|
|||
|
|
Do **not** put an entire body paragraph into `title`. `title` should be concise enough for a two-line card/list title.
|
|||
|
|
|
|||
|
|
Examples:
|
|||
|
|
|
|||
|
|
| Good title | Bad title |
|
|||
|
|
| ------------------------------------ | --------------------------------------------------------- |
|
|||
|
|
| `ARK 2026「共识加速计划」邀请王霸榜` | Full event body with links, schedule, rules, and hashtags |
|
|||
|
|
| `ARK 主网核心合约地址(BSC链)` | Full contract explainer paragraph |
|
|||
|
|
| `ARK灵魂五问完整视频` | Full video caption text |
|