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:
@@ -746,19 +746,15 @@ func (s *wikiIngestService) injectCrossLinks(ctx context.Context, kbID string, a
|
||||
changed := false
|
||||
|
||||
for _, ref := range allRefs {
|
||||
// Don't self-link
|
||||
if ref.slug == p.Slug {
|
||||
continue
|
||||
}
|
||||
// Skip if already linked with this slug
|
||||
if strings.Contains(content, "[["+ref.slug+"]]") {
|
||||
// Skip if already linked with this slug (either [[slug]] or [[slug|...]])
|
||||
if strings.Contains(content, "[["+ref.slug+"|") || strings.Contains(content, "[["+ref.slug+"]]") {
|
||||
continue
|
||||
}
|
||||
// Replace title mentions with [[slug]] link
|
||||
// Only replace if the title appears as a standalone term (not inside an existing link)
|
||||
if strings.Contains(content, ref.title) {
|
||||
// Replace first occurrence only (avoid over-linking)
|
||||
content = replaceFirstOutsideLinks(content, ref.title, ref.title+" [["+ref.slug+"]]")
|
||||
content = replaceFirstOutsideLinks(content, ref.title, "[["+ref.slug+"|"+ref.title+"]]")
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user