feat(posts): support short titles for resource cards
Add optional post-level and localized title fields, and use a new postTitleText helper for Resource.title so card/list surfaces prefer short backend-provided titles instead of full body text. When title is missing, fallback to the first non-empty body line, then filename, then post id. Document the backend handoff in docs/posts-title-api.md alongside the other backend task docs.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import type { Category, Resource } from "../api";
|
||||
import type { Attachment, Post } from "../types/post";
|
||||
import { postDisplayText } from "../components/messageStream/utils/postText";
|
||||
import {
|
||||
postDisplayText,
|
||||
postTitleText,
|
||||
} from "../components/messageStream/utils/postText";
|
||||
|
||||
export type PostBackedResource = Resource & {
|
||||
downloadPostId?: string;
|
||||
@@ -35,7 +38,7 @@ export function postToResource(
|
||||
categories: Category[] = [],
|
||||
): PostBackedResource {
|
||||
const first = post.attachments[0];
|
||||
const title = postDisplayText(post, lang) || first?.filename || post.id;
|
||||
const title = postTitleText(post, lang) || first?.filename || post.id;
|
||||
const category = categories.find((c) => c.id === post.categoryId);
|
||||
return {
|
||||
id: post.id,
|
||||
|
||||
Reference in New Issue
Block a user