519423cb0d
- landing/app/mira/wiki: tag=mira-wiki list now shows all wiki paragraphs (depends on KBDB tag filter exposed in matrix/kbdb commit, separate repo) - landing: app/mira hub + feed split + various WIP from prior sessions - registry/components: claude_api / kbdb_create_block / kbdb_get / km_writer / platform_crypto / auth_oauth2 contracts + main.go (accumulated) - .component-builds: pkg-lock updates + index.ts adjustments (WIP) - .agents/specs/arcrun/frontend-redesign: design notes - docs/test_credentials, docs/user_requirements/arcrun-landing-page: WIP docs - cypher-executor: auth-dispatcher / wasi-shim adjustments (WIP) Includes accumulated work from prior sessions plus the wiki UI tag-filter update that surfaces the AI-generated wiki paragraphs at /mira/wiki. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
'use client';
|
||
|
||
// Mira 共用 Markdown 渲染器(河道 + Wiki 共用)
|
||
// SDD: polaris/mira/.agents/specs/mira-app/design.md §3.5.7
|
||
|
||
import { useMemo } from 'react';
|
||
import ReactMarkdown from 'react-markdown';
|
||
import remarkGfm from 'remark-gfm';
|
||
|
||
export function MarkdownView({ text }: { text: string }) {
|
||
const cleaned = useMemo(() => stripLogseqMeta(text), [text]);
|
||
return (
|
||
<div className="mira-md">
|
||
<ReactMarkdown
|
||
remarkPlugins={[remarkGfm]}
|
||
components={{
|
||
a: ({ href, children, ...rest }) => (
|
||
<a
|
||
href={href}
|
||
target="_blank"
|
||
rel="noopener noreferrer"
|
||
className="wiki-link"
|
||
{...rest}
|
||
>
|
||
{children}
|
||
</a>
|
||
),
|
||
// 圖片不直接 inline 顯示(避免大圖打亂 feed),改成連結
|
||
img: ({ src, alt }) => {
|
||
const href = typeof src === 'string' ? src : '';
|
||
return href ? (
|
||
<a
|
||
href={href}
|
||
target="_blank"
|
||
rel="noopener noreferrer"
|
||
className="wiki-link"
|
||
style={{ fontStyle: 'italic' }}
|
||
>
|
||
🖼 {alt || 'image'}
|
||
</a>
|
||
) : null;
|
||
},
|
||
}}
|
||
>
|
||
{cleaned}
|
||
</ReactMarkdown>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
// Strip Logseq 專屬語法
|
||
// - 屬性行:`xxx:: yyy`、`collapsed:: true`、`id:: ...`、`logseq.order-list-type:: ...`
|
||
// - block ref:`((uuid))` 暫時保留為純文字
|
||
export function stripLogseqMeta(text: string): string {
|
||
return text
|
||
.split('\n')
|
||
.filter((line) => {
|
||
const trimmed = line.trimStart();
|
||
if (/^[a-zA-Z][a-zA-Z0-9_.-]*::\s/.test(trimmed)) return false;
|
||
return true;
|
||
})
|
||
.join('\n');
|
||
}
|