diff --git a/src/components/AIQueryInterface.astro b/src/components/AIQueryInterface.astro index 34600f6..713b76d 100644 --- a/src/components/AIQueryInterface.astro +++ b/src/components/AIQueryInterface.astro @@ -616,7 +616,7 @@ document.addEventListener('DOMContentLoaded', () => { - Passende Tool-Empfehlungen + Passende Empfehlungen
Basierend auf Ihrer Anfrage: "${originalQuery.slice(0, 100)}${originalQuery.length > 100 ? '...' : ''}" diff --git a/src/env.d.ts b/src/env.d.ts index a056e36..ac7b42e 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -18,6 +18,11 @@ declare global { switchToAIView?: () => void; clearTagFilters?: () => void; clearAllFilters?: () => void; + + // CONSOLIDATED: Tool utility functions + createToolSlug: (toolName: string) => string; + findToolByIdentifier: (tools: any[], identifier: string) => any | undefined; + isToolHosted: (tool: any) => boolean; } } diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 7d6bbb3..66956bb 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -23,8 +23,8 @@ const { title, description = 'CC24-Guide - A comprehensive directory of digital - - + + diff --git a/src/scripts/tool-utils.ts b/src/scripts/tool-utils.ts deleted file mode 100644 index 936410e..0000000 --- a/src/scripts/tool-utils.ts +++ /dev/null @@ -1,52 +0,0 @@ -// Client-side tool utilities -// Mirrors server-side function logic for consistency - -/** - * Creates a URL-safe slug from a tool name (client-side version) - */ -function createToolSlug(toolName) { - if (!toolName || typeof toolName !== 'string') { - console.warn('[toolUtils] Invalid toolName provided:', toolName); - return ''; - } - - return toolName.toLowerCase() - .replace(/[^a-z0-9\s-]/g, '') // Remove special characters - .replace(/\s+/g, '-') // Replace spaces with hyphens - .replace(/-+/g, '-') // Remove duplicate hyphens - .replace(/^-|-$/g, ''); // Remove leading/trailing hyphens -} - -/** - * Finds a tool by name or slug from tools array (client-side version) - */ -function findToolByIdentifier(tools, identifier) { - if (!identifier || !Array.isArray(tools)) return undefined; - - return tools.find(tool => - tool.name === identifier || - createToolSlug(tool.name) === identifier.toLowerCase() - ); -} - -/** - * Checks if tool has a valid project URL (hosted on CC24 server) - */ -function isToolHosted(tool) { - return tool.projectUrl !== undefined && - tool.projectUrl !== null && - tool.projectUrl !== "" && - tool.projectUrl.trim() !== ""; -} - -// Make functions available globally for existing code compatibility -window.createToolSlug = createToolSlug; -window.findToolByIdentifier = findToolByIdentifier; -window.isToolHosted = isToolHosted; - -// Export for module usage -if (typeof module !== 'undefined' && module.exports) { - module.exports = { createToolSlug, findToolByIdentifier, isToolHosted }; -} - -console.log('Tool utilities loaded'); \ No newline at end of file diff --git a/src/utils/toolHelpers.ts b/src/utils/toolHelpers.ts index 01393f5..c18a665 100644 --- a/src/utils/toolHelpers.ts +++ b/src/utils/toolHelpers.ts @@ -1,5 +1,6 @@ /** - * Tool utility functions for consistent tool operations across the app + * CONSOLIDATED Tool utility functions for consistent tool operations across the app + * Works in both server (Node.js) and client (browser) environments */ export interface Tool { @@ -65,4 +66,26 @@ export function getToolCategory(tool: Tool): 'concept' | 'method' | 'hosted' | ' if (isToolHosted(tool)) return 'hosted'; if (tool.license && tool.license !== 'Proprietary') return 'oss'; return 'proprietary'; +} + +// BROWSER COMPATIBILITY LAYER +// Only assign to window if we're in a browser environment +if (typeof window !== 'undefined') { + // Make functions available globally for existing code compatibility + window.createToolSlug = createToolSlug; + window.findToolByIdentifier = findToolByIdentifier; + window.isToolHosted = isToolHosted; + + console.log('[toolHelpers] Consolidated tool utilities loaded and assigned to window'); +} + +// LEGACY NODE.JS COMPATIBILITY +// Support for older require() patterns if needed +if (typeof module !== 'undefined' && module.exports) { + module.exports = { + createToolSlug, + findToolByIdentifier, + isToolHosted, + getToolCategory + }; } \ No newline at end of file