mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat: modality-based URLs (/image/resize, /video/compress-video)
Tool routes now include the modality prefix: /image/crop, /video/trim-video, /audio/convert-audio, /document/merge-pdf, /data/csv-json. Old URLs (e.g. /resize) redirect to the new modality-prefixed path automatically. Routes are computed by prepending MODALITY_URL_SLUG to each tool's route in the TOOLS array at module init. The App.tsx route changed from /:toolId to /:modality/:toolId, with a LegacyToolRedirect fallback.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { AUDIO_INPUTS, IMAGE_INPUTS, SUBTITLE_INPUTS, VIDEO_INPUTS } from "./modality.js";
|
||||
import { AUDIO_INPUTS, IMAGE_INPUTS, MODALITY_URL_SLUG, SUBTITLE_INPUTS, VIDEO_INPUTS } from "./modality.js";
|
||||
import type { CategoryInfo, SocialMediaPreset, Tool } from "./types.js";
|
||||
|
||||
export const CATEGORIES: CategoryInfo[] = [
|
||||
@@ -1783,6 +1783,10 @@ export const TOOLS: Tool[] = [
|
||||
},
|
||||
];
|
||||
|
||||
for (const tool of TOOLS) {
|
||||
tool.route = `/${MODALITY_URL_SLUG[tool.modality]}${tool.route}`;
|
||||
}
|
||||
|
||||
export const SOCIAL_MEDIA_PRESETS: SocialMediaPreset[] = [
|
||||
{ platform: "Instagram", name: "Post (Square)", width: 1080, height: 1080 },
|
||||
{ platform: "Instagram", name: "Story / Reel", width: 1080, height: 1920 },
|
||||
|
||||
@@ -119,6 +119,14 @@ export const DOCUMENT_INPUTS = [
|
||||
];
|
||||
export const FILE_INPUTS = [".csv", ".json", ".xml", ".yaml", ".yml", ".zip"];
|
||||
|
||||
export const MODALITY_URL_SLUG: Record<Modality, string> = {
|
||||
image: "image",
|
||||
video: "video",
|
||||
audio: "audio",
|
||||
document: "document",
|
||||
file: "data",
|
||||
};
|
||||
|
||||
export function detectModalityFromMime(mime: string): Modality {
|
||||
if (mime.startsWith("image/")) return "image";
|
||||
if (mime.startsWith("video/")) return "video";
|
||||
|
||||
Reference in New Issue
Block a user