Compare commits
2
Commits
446c1d4cec
..
next
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8596500665 | ||
|
|
2690754abd |
@@ -20,23 +20,6 @@ export interface IChatMessage {
|
|||||||
sources?: IChatSource[];
|
sources?: IChatSource[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function stripNumericPrefixes(p: string): string {
|
|
||||||
return p
|
|
||||||
.split('/')
|
|
||||||
.map((seg) => seg.replace(/^\d+-/, ''))
|
|
||||||
.join('/');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function sourceToUrl(file: string, anchor: string): string {
|
export function sourceToUrl(file: string, anchor: string): string {
|
||||||
let p = file.replace(/^docs\//, '').replace(/\.md$/, '');
|
return `/${file}${anchor ? `#${anchor}` : ''}`;
|
||||||
|
|
||||||
p = stripNumericPrefixes(p);
|
|
||||||
|
|
||||||
return `/docs/${p}${anchor ? `#${anchor}` : ''}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function sourceToPath(file: string): string {
|
|
||||||
const p = file.replace(/^docs\//, '').replace(/\.md$/, '');
|
|
||||||
|
|
||||||
return stripNumericPrefixes(p);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export function Message({ role, content, sources }: MessageProps): ReactNode {
|
|||||||
to={sourceToUrl(src.file, src.anchor)}
|
to={sourceToUrl(src.file, src.anchor)}
|
||||||
className={b('sourceLink')}
|
className={b('sourceLink')}
|
||||||
>
|
>
|
||||||
{src.heading || sourceToPath(src.file)}
|
{src.heading}
|
||||||
</Link>
|
</Link>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user