diff --git a/utils/getFileIcon.ts b/utils/getFileIcon.ts index 9d345dc..35f8015 100644 --- a/utils/getFileIcon.ts +++ b/utils/getFileIcon.ts @@ -73,6 +73,7 @@ const extensions = { rs: icons.code, vue: icons.code, json: icons.code, + yml: icons.code, yaml: icons.code, toml: icons.code, diff --git a/utils/getPreviewType.ts b/utils/getPreviewType.ts index a6c5d3b..9c180c4 100644 --- a/utils/getPreviewType.ts +++ b/utils/getPreviewType.ts @@ -1,3 +1,5 @@ +import { getExtension } from './getFileIcon' + export const preview = { markdown: 'markdown', image: 'image', @@ -47,6 +49,7 @@ export const extensions = { rs: preview.code, vue: preview.code, json: preview.code, + yml: preview.code, yaml: preview.code, toml: preview.code, @@ -94,3 +97,27 @@ export function getPreviewType(extension: string, flags?: { video?: boolean }): return previewType } + +export function getLanguageByFileName(filename: string): string { + const extension = getExtension(filename) + switch (extension) { + case 'ts': + case 'tsx': + return 'typescript' + case 'rs': + return 'rust' + case 'js': + case 'jsx': + return 'javascript' + case 'sh': + return 'shell' + case 'cs': + return 'csharp' + case 'py': + return 'python' + case 'yml': + return 'yaml' + default: + return extension + } +}