Skip to content

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

FunctionDescription
filterByStatusFilter projects by status
filterByTypeFilter projects by type
filterByFeaturedFilter featured/non-featured projects

Sorting

FunctionDescription
sortByDateSort projects by date
sortByNameSort projects alphabetically
sortByStarsSort GitHub projects by stars
sortProjectsUnified sorting by stars/name/date

React Hooks

FunctionDescription
useProjectSearchFuzzy search projects by name, description, stack
useProjectFiltersFilter projects by tags

Data Normalization

FunctionDescription
normaliseTransform project input to normalized project
normalizeStatsFormat stats for display

Data Fetching

FunctionDescription
fetchGitHubRepoFetch GitHub repository data
fetchGitHubReposFetch all repositories for a GitHub user
fetchNpmPackageFetch npm package data
fetchProductHuntPostFetch Product Hunt post data
fetchYouTubeChannelFetch YouTube channel data
fetchGumroadProductFetch Gumroad product data
fetchLemonSqueezyStoreFetch Lemon Squeezy store data
fetchDevToUserFetch Dev.to user data

Search Configuration

FunctionDescription
getFuseOptionsGet Fuse.js search configuration
createFuseSearchCreate Fuse.js search instance

SEO & Metadata

FunctionDescription
generatePersonSchemaGenerate Schema.org Person JSON-LD structured data
generateProjectSchemaGenerate Schema.org SoftwareApplication JSON-LD structured data
generatePortfolioMetadataGenerate Next.js metadata for portfolio homepage
generateProjectMetadataGenerate Next.js metadata for individual project pages

Configuration

FunctionDescription
defineProjectsType-safe project configuration helper
formatZodErrorFormat 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')