Script {scriptPath}
- {#if lang == 'python3'}
-
- {:else if lang == 'deno'}
-
- {/if}
+
diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts
index fc72f4801b..5bdcf1e1e2 100644
--- a/frontend/src/lib/utils.ts
+++ b/frontend/src/lib/utils.ts
@@ -56,9 +56,8 @@ export function displayDate(dateString: string | undefined): string {
if (date.toString() === 'Invalid Date') {
return ''
} else {
- return `${date.getFullYear()}/${
- date.getMonth() + 1
- }/${date.getDate()} at ${date.toLocaleTimeString()}`
+ return `${date.getFullYear()}/${date.getMonth() + 1
+ }/${date.getDate()} at ${date.toLocaleTimeString()}`
}
}
@@ -470,14 +469,16 @@ export function scriptPathToHref(path: string): string {
export async function getScriptByPath(path: string): Promise<{
content: string
- language: 'deno' | 'python3' | 'go'
+ language: 'deno' | 'python3' | 'go',
+ schema: any
}> {
if (path.startsWith('hub/')) {
const { content, language, schema } = await ScriptService.getHubScriptByPath({ path })
return {
content,
- language
+ language,
+ schema
}
} else {
const script = await ScriptService.getScriptByPath({
@@ -486,7 +487,8 @@ export async function getScriptByPath(path: string): Promise<{
})
return {
content: script.content,
- language: script.language
+ language: script.language,
+ schema: script.schema
}
}
}
diff --git a/frontend/src/routes/scripts.svelte b/frontend/src/routes/scripts.svelte
index 2ab0c238e8..5de1c41fa5 100644
--- a/frontend/src/routes/scripts.svelte
+++ b/frontend/src/routes/scripts.svelte
@@ -37,10 +37,9 @@
import ShareModal from '$lib/components/ShareModal.svelte'
import Tooltip from '$lib/components/Tooltip.svelte'
import TableCustom from '$lib/components/TableCustom.svelte'
- import { Highlight } from 'svelte-highlight'
- import { typescript } from 'svelte-highlight/languages/typescript'
import { Button, Tabs, Tab, Badge, Skeleton } from '$lib/components/common'
import CreateActions from '$lib/components/scripts/CreateActions.svelte'
+ import HighlightCode from '$lib/components/HighlightCode.svelte'
type Tab = 'all' | 'personal' | 'groups' | 'shared' | 'examples' | 'hub'
type Section = [string, ScriptW[]]
@@ -70,6 +69,7 @@
let codeViewer: Modal
let codeViewerContent: string = ''
+ let codeViewerLanguage: 'deno' | 'python3' | 'go' = 'deno'
let codeViewerPath: string = ''
$: filteredScripts =
@@ -131,7 +131,9 @@
}
async function viewCode(path: string) {
- codeViewerContent = (await getScriptByPath(path)).content
+ const { content, language } = await getScriptByPath(path)
+ codeViewerContent = content
+ codeViewerLanguage = language
codeViewerPath = path
codeViewer.openModal()
}
@@ -153,7 +155,7 @@