From a97b10ba3104e02b9a2fe1c3a894cf212e773fe2 Mon Sep 17 00:00:00 2001 From: syui Date: Thu, 19 Feb 2026 08:18:02 +0900 Subject: [PATCH] add old lexicon merge --- src/web/components/posts.ts | 32 ++++++++++++++++++------- src/web/main.ts | 48 ++++++++++++++++++++++++++++++++++--- src/web/styles/main.css | 24 +++++++++++++++++++ 3 files changed, 93 insertions(+), 11 deletions(-) diff --git a/src/web/components/posts.ts b/src/web/components/posts.ts index 50da3be..03c8a73 100644 --- a/src/web/components/posts.ts +++ b/src/web/components/posts.ts @@ -3,6 +3,17 @@ import { renderMarkdown } from '../lib/markdown' import { renderDiscussion, loadDiscussionPosts } from './discussion' import { getCurrentLang } from './mode-tabs' +// Extract text content from post content (handles both string and object formats) +function getContentText(content: unknown): string { + if (!content) return '' + if (typeof content === 'string') return content + if (typeof content === 'object' && content !== null) { + const obj = content as Record + if (typeof obj.text === 'string') return obj.text + } + return '' +} + // Format date as yyyy/mm/dd function formatDate(dateStr: string): string { const d = new Date(dateStr) @@ -52,7 +63,8 @@ export function renderPostDetail( collection: string, isOwner: boolean = false, siteUrl?: string, - appUrl: string = 'https://bsky.app' + appUrl: string = 'https://bsky.app', + canMerge: boolean = false ): string { const rkey = post.uri.split('/').pop() || '' const date = formatDate(post.value.publishedAt) @@ -61,29 +73,32 @@ export function renderPostDetail( // Build post URL for discussion search const postUrl = siteUrl ? `${siteUrl}/@${handle}/${rkey}` : `${window.location.origin}/@${handle}/${rkey}` + const rawContent = getContentText(post.value.content) + const editBtn = isOwner ? `` : '' + const mergeBtn = canMerge ? `` : '' // Get current language and show appropriate content const currentLang = getCurrentLang() const translations = post.value.translations const originalLang = post.value.langs?.[0] || 'ja' - let displayTitle = post.value.title - let displayContent = post.value.content.text + let displayTitle = post.value.title || '' + let displayContent = rawContent // Use translation if available and not original language if (translations && currentLang !== originalLang && translations[currentLang]) { const trans = translations[currentLang] - displayTitle = trans.title || post.value.title - displayContent = trans.content + displayTitle = trans.title || post.value.title || '' + displayContent = trans.content || rawContent } - const content = renderMarkdown(displayContent) + const content = displayContent ? renderMarkdown(displayContent) : '' const editForm = isOwner ? `