From 391c837b37de57cb182cbfadda143299b02e4472 Mon Sep 17 00:00:00 2001 From: Jay V Date: Fri, 27 Jun 2025 13:25:15 -0400 Subject: [PATCH] docs: share page write tool bug --- packages/web/src/components/Share.tsx | 14 +++++++------- packages/web/src/types/lang-map.d.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/packages/web/src/components/Share.tsx b/packages/web/src/components/Share.tsx index a61852d9..0e58312c 100644 --- a/packages/web/src/components/Share.tsx +++ b/packages/web/src/components/Share.tsx @@ -84,7 +84,7 @@ function scrollToAnchor(id: string) { el.scrollIntoView({ behavior: "smooth" }) } -function stripWorkingDirectory(filePath: string, workingDir?: string) { +function stripWorkingDirectory(filePath?: string, workingDir?: string) { if (filePath === undefined || workingDir === undefined) return filePath const prefix = workingDir.endsWith("/") ? workingDir : workingDir + "/" @@ -1228,9 +1228,9 @@ export default function Share(props: { const path = createMemo(() => toolData()?.args.path !== data().rootDir ? stripWorkingDirectory( - toolData()?.args.path, - data().rootDir, - ) + toolData()?.args.path, + data().rootDir, + ) : toolData()?.args.path, ) @@ -1391,7 +1391,7 @@ export default function Share(props: { {(_part) => { const filePath = createMemo(() => stripWorkingDirectory( - toolData()?.args.filePath, + toolData()?.args?.filePath, data().rootDir, ), ) @@ -1430,7 +1430,7 @@ export default function Share(props: {
{formatErrorString( - toolData()?.result, + toolData()?.result )}
@@ -1449,7 +1449,7 @@ export default function Share(props: {
diff --git a/packages/web/src/types/lang-map.d.ts b/packages/web/src/types/lang-map.d.ts index e69de29b..b21d2a00 100644 --- a/packages/web/src/types/lang-map.d.ts +++ b/packages/web/src/types/lang-map.d.ts @@ -0,0 +1,27 @@ +declare module "lang-map" { + /** Returned by calling `map()` */ + export interface MapReturn { + /** All extensions keyed by language name */ + extensions: Record; + /** All languages keyed by file-extension */ + languages: Record; + } + + /** + * Calling `map()` gives you the raw lookup tables: + * + * ```js + * const { extensions, languages } = map(); + * ``` + */ + function map(): MapReturn; + + /** Static method: get extensions for a given language */ + namespace map { + function extensions(language: string): string[]; + /** Static method: get languages for a given extension */ + function languages(extension: string): string[]; + } + + export = map; +}