-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathconfig.ts
More file actions
87 lines (71 loc) · 2.93 KB
/
Copy pathconfig.ts
File metadata and controls
87 lines (71 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
export const languages = {
// English (default)
"en": { label: "English", path: "/en/" },
// Western European – Romance
"fr": { label: "Français", path: "/fr/" },
"es": { label: "Español", path: "/es/" },
"ca": { label: "Català", path: "/ca/" },
"it": { label: "Italiano", path: "/it/" },
"pt-BR": { label: "Português", path: "/pt-BR/" },
// Western European – Germanic & Nordic
"de": { label: "Deutsch", path: "/de/" },
"da": { label: "Dansk", path: "/da/" },
"fi": { label: "Suomi", path: "/fi/" },
"nl": { label: "Nederlands", path: "/nl/" },
// Central & Eastern European
"pl": { label: "Polski", path: "/pl/" },
"cs": { label: "Čeština", path: "/cs/" },
"sk": { label: "Slovenčina", path: "/sk/" },
"sq": { label: "Shqip", path: "/sq/" },
"el": { label: "Ελληνικά", path: "/el/" },
"ru": { label: "Русский", path: "/ru/" },
"uk": { label: "Українська", path: "/uk/" },
"hu": { label: "Magyar", path: "/hu/" },
"bg": { label: "Български", path: "/bg/" },
"be": { label: "Беларуская", path: "/be/" },
// Turkic & Central Asian
"tr": { label: "Türkçe", path: "/tr/" },
"kk": { label: "Қазақша", path: "/kk/" },
// Middle Eastern
"he": { label: "עברית", path: "/he/" },
"ar": { label: "العربية", path: "/ar/" },
"fa": { label: "فارسی", path: "/fa/" },
// South & Southeast Asian
"vi": { label: "Tiếng Việt", path: "/vi/" },
"th": { label: "ไทย", path: "/th/" },
"id": { label: "Indonesia", path: "/id/" },
"tl": { label: "Tagalog", path: "/tl/" },
"bn": { label: "বাংলা", path: "/bn/" },
"hi": { label: "हिंदी", path: "/hi/"},
// CJK (East Asian)
"zh-CN": { label: "简体中文", path: "/zh-CN/" },
"zh-TW": { label: "正體中文", path: "/zh-TW/" },
"ja": { label: "日本語", path: "/ja/" },
"ko": { label: "한국어", path: "/ko/" },
// Language isolate
"eu": { label: "Euskara", path: "eu" },
} as const;
export type Locale = keyof typeof languages;
export const defaultLocale: Locale = "en";
const rtlLanguages = new Set(["ar", "he", "fa", "ur"]);
/** Returns true if the given language code is a right-to-left script. */
export function isRtl(lang: string): boolean {
return rtlLanguages.has(lang.split("-")[0].toLowerCase());
}
import { marked } from "marked";
// Add target="_blank" to external links rendered by marked
marked.use({
renderer: {
link({ href, title, tokens }) {
const text = this.parser.parseInline(tokens);
const isExternal = /^https?:\/\//.test(href ?? '');
const target = isExternal ? ' target="_blank"' : '';
const titleAttr = title ? ` title="${title}"` : '';
return `<a href="${href}"${titleAttr}${target}>${text}</a>`;
}
}
});
/** Render a markdown string to inline HTML (no wrapping <p> tags). */
export function markdownify(text: string): string {
return marked.parseInline(text) as string;
}