diff options
| author | zwlucas <lucas.fariamo08@gmail.com> | 2026-06-05 20:52:54 +0000 |
|---|---|---|
| committer | zwlucas <lucas.fariamo08@gmail.com> | 2026-06-05 20:52:54 +0000 |
| commit | 09f964451d7d92e9891430ec4595c1276d486aab (patch) | |
| tree | 28da4483f5c28924a8c47fceb648b1baebe88224 /src/lib/languageMap.ts | |
| download | yace-master.tar.gz yace-master.zip | |
Signed-off-by: zwlucas <lucas.fariamo08@gmail.com>
Diffstat (limited to 'src/lib/languageMap.ts')
| -rw-r--r-- | src/lib/languageMap.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/languageMap.ts b/src/lib/languageMap.ts new file mode 100644 index 0000000..ec8d6b7 --- /dev/null +++ b/src/lib/languageMap.ts @@ -0,0 +1,23 @@ +import type { Language } from '@/types' + +const extensionMap: Record<string, Language> = { + ts: 'typescript', + tsx: 'typescript', + js: 'javascript', + jsx: 'javascript', + mjs: 'javascript', + cjs: 'javascript', + rs: 'rust', + json: 'json', + md: 'markdown', + mdx: 'markdown', + html: 'html', + htm: 'html', + css: 'css', + py: 'python', +} + +export function detectLanguage(filename: string): Language { + const ext = filename.split('.').pop()?.toLowerCase() ?? '' + return extensionMap[ext] ?? 'plaintext' +} |