Utilities
Projex provides utility functions for filtering, sorting, and normalizing project data. All utilities are pure functions that can be used in build-time data preparation.
Available Utilities
Filtering
| Function | Description |
|---|---|
| filterByStatus | Filter projects by status |
| filterByType | Filter projects by type |
| filterByFeatured | Filter featured/non-featured projects |
Sorting
| Function | Description |
|---|---|
| sortByDate | Sort projects by date |
| sortByName | Sort projects alphabetically |
| sortByStars | Sort GitHub projects by stars |
| sortProjects | Unified sorting by stars/name/date |
React Hooks
| Function | Description |
|---|---|
| useProjectSearch | Fuzzy search projects by name, description, stack |
| useProjectFilters | Filter projects by tags |
Data Normalization
| Function | Description |
|---|---|
| normalise | Transform project input to normalized project |
| normalizeStats | Format stats for display |
Data Fetching
| Function | Description |
|---|---|
| fetchGitHubRepo | Fetch GitHub repository data |
| fetchGitHubRepos | Fetch all repositories for a GitHub user |
| fetchNpmPackage | Fetch npm package data |
| fetchProductHuntPost | Fetch Product Hunt post data |
| fetchYouTubeChannel | Fetch YouTube channel data |
| fetchGumroadProduct | Fetch Gumroad product data |
| fetchLemonSqueezyStore | Fetch Lemon Squeezy store data |
| fetchDevToUser | Fetch Dev.to user data |
Search Configuration
| Function | Description |
|---|---|
| getFuseOptions | Get Fuse.js search configuration |
| createFuseSearch | Create Fuse.js search instance |
SEO & Metadata
| Function | Description |
|---|---|
| generatePersonSchema | Generate Schema.org Person JSON-LD structured data |
| generateProjectSchema | Generate Schema.org SoftwareApplication JSON-LD structured data |
| generatePortfolioMetadata | Generate Next.js metadata for portfolio homepage |
| generateProjectMetadata | Generate Next.js metadata for individual project pages |
Configuration
| Function | Description |
|---|---|
| defineProjects | Type-safe project configuration helper |
| formatZodError | Format Zod validation errors with helpful suggestions |
Import
tsx
import {
filterByStatus,
filterByType,
filterByFeatured,
sortByDate,
sortByName,
sortByStars,
sortProjects,
useProjectSearch,
useProjectFilters,
normalise,
normalizeStats,
defineProjects,
fetchGitHubRepo,
fetchGitHubRepos,
fetchNpmPackage,
fetchProductHuntPost,
fetchYouTubeChannel,
fetchGumroadProduct,
fetchLemonSqueezyStore,
fetchDevToUser,
getFuseOptions,
createFuseSearch,
generatePersonSchema,
generateProjectSchema,
generatePortfolioMetadata,
generateProjectMetadata,
formatZodError
} from '@manningworks/projex'Common Patterns
Chaining Filters and Sorts
tsx
import { filterByStatus, filterByFeatured, sortByDate } from '@manningworks/projex'
const activeProjects = filterByStatus(projects, 'active')
const featuredActive = filterByFeatured(activeProjects, true)
const sorted = sortByDate(featuredActive, 'desc')Build-Time Data Preparation
tsx
import { defineProjects, normalise, sortByStars } from '@manningworks/projex'
const { projects, options } = defineProjects([
{ id: 'proj-1', type: 'github', repo: 'user/repo', status: 'active' },
{ id: 'proj-2', type: 'npm', package: 'my-package', status: 'shipped' },
])
const normalised = await Promise.all(projects.map(p => normalise(p, options)))
export const sortedProjects = sortByStars(normalised, 'desc')