File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
src/interfaces/assistants_web/src/components/Markdown/tags Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -6,19 +6,21 @@ import { ComponentPropsWithoutRef } from 'react';
66import { Icon } from '@/components/UI' ;
77import { useOutputFiles } from '@/stores' ;
88
9- export const Anchor : Component < ComponentPropsWithoutRef < 'a' > & ExtraProps > = ( { children } ) => {
9+ export const Anchor : Component < ComponentPropsWithoutRef < 'a' > & ExtraProps > = ( {
10+ children,
11+ node,
12+ } ) => {
1013 const { outputFiles } = useOutputFiles ( ) ;
14+ const nodeHref = node ?. properties . href ;
15+
16+ if ( typeof children === 'string' && typeof nodeHref === 'string' ) {
17+ const outputFile = Object . entries ( outputFiles ) . find ( ( [ key ] ) => nodeHref . includes ( key ) ) ?. [ 1 ] ;
1118
12- if ( typeof children === 'string' ) {
13- const snakeCaseUrl = children . replace ( / \s / g, '_' ) . toLowerCase ( ) ;
14- const outputFile = Object . entries ( outputFiles ) . find ( ( [ key ] ) =>
15- key . startsWith ( snakeCaseUrl )
16- ) ?. [ 1 ] ;
1719 const downloadUrl = outputFile ?. downloadUrl ;
1820
1921 if ( downloadUrl ) {
2022 return (
21- < a href = { downloadUrl } download = { snakeCaseUrl } className = "flex items-center gap-1" >
23+ < a href = { downloadUrl } download = { outputFile . name } className = "flex items-center gap-1" >
2224 { children }
2325 < Icon name = "download" />
2426 </ a >
You can’t perform that action at this time.
0 commit comments