Emdash source with visual editor image upload fix

Fixes:
1. media.ts: wrap placeholder generation in try-catch
2. toolbar.ts: check r.ok, display error message in popover
This commit is contained in:
2026-05-03 10:44:54 +07:00
parent 78f81bebb6
commit 2d1be52177
2352 changed files with 662964 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
/**
* Shared content helpers for ATProto outputs.
*
* These helpers intentionally stay small and boring so standard.site and
* Bluesky can share path/field lookup behavior without coupling their
* output-specific formatting logic.
*/
export function getString(obj: Record<string, unknown>, key: string): string | undefined {
const value = obj[key];
return typeof value === "string" && value.length > 0 ? value : undefined;
}
export function getContentData(content: Record<string, unknown>): Record<string, unknown> {
return content.data && typeof content.data === "object"
? (content.data as Record<string, unknown>)
: {};
}
export function getContentString(
content: Record<string, unknown>,
key: string,
): string | undefined {
return getString(content, key) || getString(getContentData(content), key);
}
export function buildContentPath(
collection: string | undefined,
content: Record<string, unknown>,
): string | undefined {
const slug = getContentString(content, "slug");
if (!slug) return undefined;
if (!collection || collection === "pages") return `/${slug}`;
return `/${collection}/${slug}`;
}