|
| 1 | +import { isMarkdownFileLinkLabel } from "@t3tools/client-runtime/markdown-links"; |
| 2 | +import { nodeTextContent } from "@t3tools/mobile-markdown-text/markdown"; |
1 | 3 | import * as Haptics from "expo-haptics"; |
2 | 4 | import { KeyboardAwareLegendList } from "@legendapp/list/keyboard"; |
3 | 5 | import { useViewabilityAmount, type LegendListRef } from "@legendapp/list/react-native"; |
@@ -1055,21 +1057,26 @@ function useMarkdownStyles( |
1055 | 1057 | preserveSoftBreaks: boolean, |
1056 | 1058 | highlightCode: boolean, |
1057 | 1059 | ): CustomRenderers => ({ |
1058 | | - link: ({ children, href = "" }) => { |
| 1060 | + link: ({ node, children, href = "" }) => { |
1059 | 1061 | const presentation = resolveMarkdownLinkPresentation(href); |
1060 | 1062 | if (presentation.kind === "file") { |
| 1063 | + const descriptive = !isMarkdownFileLinkLabel(nodeTextContent(node), href); |
1061 | 1064 | return ( |
1062 | | - <NativeText |
1063 | | - className="font-t3-bold" |
1064 | | - onPress={() => onLinkPress(href)} |
1065 | | - style={{ color: inlineTextColor }} |
1066 | | - > |
1067 | | - <Image |
1068 | | - source={markdownFileIconSource(presentation.icon)} |
1069 | | - style={markdownLinkStyles.inlineIcon} |
1070 | | - /> |
1071 | | - {presentation.label} |
1072 | | - </NativeText> |
| 1065 | + <MarkdownLinkLabelContext.Provider value> |
| 1066 | + <NativeText |
| 1067 | + className="font-t3-bold" |
| 1068 | + onPress={() => onLinkPress(href)} |
| 1069 | + style={{ color: inlineTextColor }} |
| 1070 | + > |
| 1071 | + {descriptive ? <>{children} (</> : null} |
| 1072 | + <Image |
| 1073 | + source={markdownFileIconSource(presentation.icon)} |
| 1074 | + style={markdownLinkStyles.inlineIcon} |
| 1075 | + /> |
| 1076 | + {presentation.label} |
| 1077 | + {descriptive ? ")" : null} |
| 1078 | + </NativeText> |
| 1079 | + </MarkdownLinkLabelContext.Provider> |
1073 | 1080 | ); |
1074 | 1081 | } |
1075 | 1082 | if (presentation.kind === "external") { |
|
0 commit comments