feat: image compress before upload
This commit is contained in:
@@ -351,6 +351,37 @@ export function referenceFromUrl(
|
||||
return { title: bookName, detail: null };
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a post's source into structured `{ title, detail }` for
|
||||
* multi-line share/copy payloads. Mirrors the formatCopyText pattern
|
||||
* from selection-toolbar/shared.tsx so Send + Copy produce the same
|
||||
* citation block.
|
||||
*
|
||||
* Two routes to the structured shape:
|
||||
*
|
||||
* 1. Book URLs → `referenceFromUrl` parses the path.
|
||||
* 2. Anything else (letters, essays, transcriptions, magazines):
|
||||
* `source_title` was composed by compose-post.tsx as
|
||||
* "Title — Detail" using ` — ` as the join. Split on the first
|
||||
* occurrence to recover the structured fields.
|
||||
*
|
||||
* Falls back to title-only with no detail when no separator is present.
|
||||
*/
|
||||
export function structuredReferenceForPost(
|
||||
sourceUrl: string,
|
||||
sourceTitle: string | null | undefined,
|
||||
): { title: string; detail: string | null } {
|
||||
const r = referenceFromUrl(sourceUrl);
|
||||
if (r) return r;
|
||||
const stored = sourceTitle?.trim() || "Source";
|
||||
const idx = stored.indexOf(" — ");
|
||||
if (idx === -1) return { title: stored, detail: null };
|
||||
return {
|
||||
title: stored.slice(0, idx).trim(),
|
||||
detail: stored.slice(idx + 3).trim() || null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a one-line citation string for a post/bookmark card.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user