mirror of
https://github.com/sst/opencode.git
synced 2025-08-31 18:27:22 +00:00
docs: share page write tool bug
This commit is contained in:
parent
2f8cf9146b
commit
87d62514db
2 changed files with 34 additions and 7 deletions
|
@ -85,7 +85,7 @@ function scrollToAnchor(id: string) {
|
||||||
el.scrollIntoView({ behavior: "smooth" })
|
el.scrollIntoView({ behavior: "smooth" })
|
||||||
}
|
}
|
||||||
|
|
||||||
function stripWorkingDirectory(filePath: string, workingDir?: string) {
|
function stripWorkingDirectory(filePath?: string, workingDir?: string) {
|
||||||
if (filePath === undefined || workingDir === undefined) return filePath
|
if (filePath === undefined || workingDir === undefined) return filePath
|
||||||
|
|
||||||
const prefix = workingDir.endsWith("/") ? workingDir : workingDir + "/"
|
const prefix = workingDir.endsWith("/") ? workingDir : workingDir + "/"
|
||||||
|
@ -1307,9 +1307,9 @@ export default function Share(props: {
|
||||||
const path = createMemo(() =>
|
const path = createMemo(() =>
|
||||||
toolData()?.args.path !== data().rootDir
|
toolData()?.args.path !== data().rootDir
|
||||||
? stripWorkingDirectory(
|
? stripWorkingDirectory(
|
||||||
toolData()?.args.path,
|
toolData()?.args.path,
|
||||||
data().rootDir,
|
data().rootDir,
|
||||||
)
|
)
|
||||||
: toolData()?.args.path,
|
: toolData()?.args.path,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1470,7 +1470,7 @@ export default function Share(props: {
|
||||||
{(_part) => {
|
{(_part) => {
|
||||||
const filePath = createMemo(() =>
|
const filePath = createMemo(() =>
|
||||||
stripWorkingDirectory(
|
stripWorkingDirectory(
|
||||||
toolData()?.args.filePath,
|
toolData()?.args?.filePath,
|
||||||
data().rootDir,
|
data().rootDir,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -1509,7 +1509,7 @@ export default function Share(props: {
|
||||||
<div data-part-tool-result>
|
<div data-part-tool-result>
|
||||||
<ErrorPart>
|
<ErrorPart>
|
||||||
{formatErrorString(
|
{formatErrorString(
|
||||||
toolData()?.result,
|
toolData()?.result
|
||||||
)}
|
)}
|
||||||
</ErrorPart>
|
</ErrorPart>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1528,7 +1528,7 @@ export default function Share(props: {
|
||||||
<div data-part-tool-code>
|
<div data-part-tool-code>
|
||||||
<CodeBlock
|
<CodeBlock
|
||||||
lang={getShikiLang(filePath())}
|
lang={getShikiLang(filePath())}
|
||||||
code={args.content}
|
code={toolData()?.args?.content}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
27
packages/web/src/types/lang-map.d.ts
vendored
27
packages/web/src/types/lang-map.d.ts
vendored
|
@ -0,0 +1,27 @@
|
||||||
|
declare module "lang-map" {
|
||||||
|
/** Returned by calling `map()` */
|
||||||
|
export interface MapReturn {
|
||||||
|
/** All extensions keyed by language name */
|
||||||
|
extensions: Record<string, string[]>;
|
||||||
|
/** All languages keyed by file-extension */
|
||||||
|
languages: Record<string, string[]>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue