lang
This commit is contained in:
41
src/lib/captionLength.ts
Normal file
41
src/lib/captionLength.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
buildPostLinkCaptionHeader,
|
||||
SelectedPostLink,
|
||||
} from "@/lib/postLinkCaption";
|
||||
import type { AppLanguage } from "@/lib/i18n/registry";
|
||||
|
||||
export const POST_CAPTION_MAX_LENGTH = 2000;
|
||||
|
||||
export function buildFullPostCaption(
|
||||
description: string,
|
||||
taggedUsers: Array<{ user_name: string }>,
|
||||
packages: SelectedPostLink[],
|
||||
projects: SelectedPostLink[],
|
||||
billboards: SelectedPostLink[],
|
||||
lang?: AppLanguage
|
||||
): string {
|
||||
const tagLine = taggedUsers.map((u) => `@${u.user_name}`).join(" ");
|
||||
const linkHeader = buildPostLinkCaptionHeader(
|
||||
[...packages, ...projects, ...billboards],
|
||||
lang
|
||||
);
|
||||
return [description.trim(), tagLine, linkHeader].filter(Boolean).join("\n");
|
||||
}
|
||||
|
||||
export function countPostCaptionLength(
|
||||
description: string,
|
||||
taggedUsers: Array<{ user_name: string }>,
|
||||
packages: SelectedPostLink[],
|
||||
projects: SelectedPostLink[],
|
||||
billboards: SelectedPostLink[],
|
||||
lang?: AppLanguage
|
||||
): number {
|
||||
return buildFullPostCaption(
|
||||
description,
|
||||
taggedUsers,
|
||||
packages,
|
||||
projects,
|
||||
billboards,
|
||||
lang
|
||||
).length;
|
||||
}
|
||||
Reference in New Issue
Block a user