Core Utility Functions
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Core Utility Functions of the SuperClaude Website encompass a variety of specialized modules designed to handle path resolution, documentation indexing, data fetching, and UI logic. These utilities ensure that the documentation-heavy site can correctly map local file paths to application routes, manage large datasets of contributors with caching mechanisms, and provide smooth visual effects.
By centralizing logic for link resolution and documentation mapping, the project maintains consistency across its Markdown-driven content. This architecture allows developers to contribute documentation without manually updating navigation structures, as utility scripts automate the discovery and indexing of new content.
Sources: scripts/generate-docs-map.js, src/utils/linkResolver.js
Documentation Mapping and Path Resolution
The system relies on a build-time script to scan the filesystem and generate a manifest of available documentation. This manifest is then consumed by client-side utilities to resolve relative links within Markdown files.
Documentation Map Generation
The utility script generate-docs-map.js parses the public/docs directory to create a structured JSON file. It enforces a specific category order (e.g., Getting-Started, User-Guide) and extracts titles directly from the H1 headers of Markdown files.
The diagram shows the automated workflow for indexing documentation files into a machine-readable format.
Sources: scripts/generate-docs-map.js:7-54
Link and Path Resolvers
To support internal navigation within Markdown content, the linkResolver.js utility provides functions to calculate absolute application paths from relative Markdown links.
| Function | Purpose | Input |
|---|---|---|
resolvePath | Converts relative file paths into absolute /docs/... paths. | (base, relative) |
resolveMarkdownLink | Maps a .md link and optional hash to a React Router route. | (href, category, file) |
Sources: src/utils/linkResolver.js:3-48
Data Loading and API Utilities
Utilities in this section handle the retrieval of external data, such as GitHub contributor information and documentation content, incorporating optimization strategies like caching and state management.
Documentation Loader Hook
The useDocumentationLoader hook abstracts the complexity of fetching Markdown files. It uses the docs-map.json to find the correct physical path for a given category and file name.
This sequence illustrates the lifecycle of loading a documentation page from a static asset.
Sources: src/hooks/useDocumentationLoader.js:7-41
Contributor Data Management
The Netlify function get-contributors.js acts as a backend utility to aggregate data from multiple GitHub repositories. It implements a 12-hour in-memory cache to stay within GitHub API rate limits.
| Logic Component | Implementation Detail |
|---|---|
| Cache Duration | 12 hours (43,200,000 ms) |
| Repos Scanned | SuperClaude_Framework, SuperClaude_Website |
| Exclusions | Bots and specific maintainers (mithun50, NomenAK) |
Sources: netlify/functions/get-contributors.js:1-25
UI and Visual Utilities
Technical utilities also support the presentation layer, focusing on CSS class management and complex animation math.
Style Merging
The project utilizes clsx and tailwind-merge within a centralized utility to handle conditional styling. This prevents class conflicts in components that accept custom className props.
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs) {
return twMerge(clsx(inputs));
}
Sources: src/lib/utils.js:1-5
Motion and Interaction Logic
The GlowingEffect utility manages high-performance mouse tracking and angle calculations to drive CSS variables for radial gradients. It uses requestAnimationFrame to ensure smooth updates without blocking the main thread.
The flow describes how the utility determines the visibility and orientation of glowing UI elements based on user proximity.
Sources: src/components/GlowingEffect.js:30-85
Conclusion
The Core Utility Functions provide the architectural backbone for the SuperClaude Website, bridging the gap between static Markdown files and a dynamic React interface. Through automated indexing, intelligent path resolution, and cached API interactions, these utilities ensure the platform remains scalable and performant.