refactor: Update wiki link syntax and rendering in WikiBrowser component

- Enhanced the `renderMarkdown` function to support the new `[[slug|display name]]` format for wiki links, improving link clarity and usability.
- Adjusted CSS styles for wiki links to provide a more intuitive hover effect and visual distinction.
- Updated prompts in the `prompts_wiki.go` file to reflect the new wiki link syntax, ensuring consistency across the application.

These changes improve the overall user experience by making wiki links more informative and visually appealing.
This commit is contained in:
wizardchen
2026-04-08 17:21:44 +08:00
parent 7eea22d655
commit 5d5073c96b
5 changed files with 24 additions and 23 deletions
@@ -288,8 +288,12 @@ const graphDrawerContent = computed(() => {
function renderMarkdown(content: string): string {
let html = content
html = html.replace(/\[\[([^\]]+)\]\]/g, (_, slug) =>
`<a href="#" class="wiki-content-link" data-slug="${slug}">[[${slug}]]</a>`)
html = html.replace(/\[\[([^\]]+)\]\]/g, (_, inner: string) => {
const pipeIdx = inner.indexOf('|')
const slug = pipeIdx > 0 ? inner.substring(0, pipeIdx).trim() : inner.trim()
const display = pipeIdx > 0 ? inner.substring(pipeIdx + 1).trim() : slugDisplayName(slug)
return `<a href="#" class="wiki-content-link" data-slug="${slug}">${display}</a>`
})
html = html.replace(/^### (.+)$/gm, '<h3>$1</h3>')
html = html.replace(/^## (.+)$/gm, '<h2>$1</h2>')
html = html.replace(/^# (.+)$/gm, '<h1>$1</h1>')
@@ -1290,13 +1294,9 @@ onMounted(() => {
:deep(.wiki-content-link) {
color: var(--td-brand-color);
text-decoration: none;
font-family: monospace;
font-size: 13px;
padding: 1px 4px;
background: rgba(7, 192, 95, 0.06);
border-radius: 3px;
border-bottom: 1px dashed var(--td-brand-color);
cursor: pointer;
&:hover { background: rgba(7, 192, 95, 0.12); }
&:hover { border-bottom-style: solid; }
}
}