@hyvor/design 1.1.7 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CodeBlock/CodeBlock.svelte +3 -2
- package/dist/components/CodeBlock/CodeBlock.svelte.d.ts +1 -1
- package/dist/components/CodeBlock/getCode.d.ts +1 -1
- package/dist/components/CodeBlock/getCode.js +3 -1
- package/dist/components/Internationalization/LanguageToggle.svelte +8 -5
- package/dist/components/Internationalization/LanguageToggle.svelte.d.ts +1 -0
- package/package.json +1 -1
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
import getCode, { type Language } from './getCode.js';
|
|
13
13
|
interface Props {
|
|
14
14
|
code: string;
|
|
15
|
-
language?: InputLanguage;
|
|
15
|
+
language?: InputLanguage | null;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
let { code, language = 'html' }: Props = $props();
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
let languageCode = $derived(language ? (languagesMap[language] || language) : null) as Language | null;
|
|
20
21
|
</script>
|
|
21
22
|
|
|
22
23
|
<pre class="language-{languageCode} hljs"><code>{@html getCode(code, languageCode)}</code></pre>
|
|
@@ -2,7 +2,7 @@ import './hljs.scss';
|
|
|
2
2
|
type InputLanguage = 'html' | 'css' | 'js' | 'ts' | 'yaml' | 'json' | 'svelte' | 'jsx' | 'php';
|
|
3
3
|
interface Props {
|
|
4
4
|
code: string;
|
|
5
|
-
language?: InputLanguage;
|
|
5
|
+
language?: InputLanguage | null;
|
|
6
6
|
}
|
|
7
7
|
declare const CodeBlock: import("svelte").Component<Props, {}, "">;
|
|
8
8
|
type CodeBlock = ReturnType<typeof CodeBlock>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type Language = 'html' | 'css' | 'js' | 'ts';
|
|
2
|
-
export default function getCode(code: string, language: Language): string;
|
|
2
|
+
export default function getCode(code: string, language: Language | null): string;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
icon?: boolean;
|
|
17
17
|
size?: 'medium' | 'small';
|
|
18
18
|
staticPage?: boolean;
|
|
19
|
+
goto?: Function; // sveltekit goto function, required for static pages
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
let {
|
|
@@ -24,7 +25,8 @@
|
|
|
24
25
|
caret = IconCaretDown,
|
|
25
26
|
icon = false,
|
|
26
27
|
size = 'medium',
|
|
27
|
-
staticPage = false
|
|
28
|
+
staticPage = false,
|
|
29
|
+
goto,
|
|
28
30
|
}: Props = $props();
|
|
29
31
|
|
|
30
32
|
const i18n = getContext<InternationalizationService>('i18n');
|
|
@@ -43,11 +45,12 @@
|
|
|
43
45
|
}
|
|
44
46
|
const url = new URL(window.location.href);
|
|
45
47
|
url.pathname = url.pathname.replace(`/${currentLocale}`, `/${language.code}`);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
await import('$app/navigation').then(({ goto }) => {
|
|
48
|
+
|
|
49
|
+
if (goto) {
|
|
49
50
|
goto(url.toString());
|
|
50
|
-
}
|
|
51
|
+
} else {
|
|
52
|
+
window.location.href = url.toString();
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
i18n.setLocale(language.code);
|
package/package.json
CHANGED