getAllMoods
Returns an array of all unique mood tags used across all font pairings in the registry.
Function Signature
export function getAllMoods () : string []
Returns
Array of all unique mood tags across all pairings
Description
The getAllMoods() function extracts and returns all unique mood values from the mood arrays of every pairing in the registry. This is useful for building filter UIs, discovering available mood categories, or analyzing the collection.
Usage Examples
Basic Usage
import { getAllMoods } from '@/lib/pairings'
const moods = getAllMoods ()
console . log ( moods )
// Output: ['minimal', 'modern', 'editorial', 'literary', 'bold', ...]
Build a Filter UI
import { getAllMoods } from '@/lib/pairings'
export function MoodFilter ({ onSelect } : { onSelect : ( mood : string ) => void }) {
const moods = getAllMoods ()
return (
< div className = "flex flex-wrap gap-2" >
{ moods . map ( mood => (
< button
key = { mood }
onClick = { () => onSelect ( mood ) }
className = "px-3 py-1 rounded-md bg-secondary hover:bg-primary"
>
{ mood }
</ button >
)) }
</ div >
)
}
Count Pairings Per Mood
import { getAllMoods , getPairingsByMood } from '@/lib/pairings'
const moods = getAllMoods ()
const moodStats = moods . map ( mood => ({
mood ,
count: getPairingsByMood ( mood ). length
}))
console . log ( moodStats )
// Output: [{ mood: 'minimal', count: 5 }, { mood: 'editorial', count: 8 }, ...]
Generate Mood Tag Cloud
import { getAllMoods , getPairingsByMood } from '@/lib/pairings'
export function MoodCloud () {
const moods = getAllMoods ()
return (
< div className = "flex flex-wrap gap-3" >
{ moods . map ( mood => {
const count = getPairingsByMood ( mood ). length
const size = Math . min ( 20 + count * 2 , 36 )
return (
< a
key = { mood }
href = { `/moods/ ${ mood } ` }
style = { { fontSize: ` ${ size } px` } }
className = "hover:underline"
>
{ mood }
</ a >
)
}) }
</ div >
)
}
import { getAllMoods } from '@/lib/pairings'
function isValidMood ( mood : string ) : boolean {
const validMoods = getAllMoods ()
return validMoods . includes ( mood )
}
// Usage in API route
export async function GET ( request : Request ) {
const { searchParams } = new URL ( request . url )
const mood = searchParams . get ( 'mood' )
if ( mood && ! isValidMood ( mood )) {
return Response . json ({ error: 'Invalid mood' }, { status: 400 })
}
// ... rest of handler
}
The registry includes moods such as:
Style : minimal, modern, clean, brutalist, nordic
Tone : editorial, literary, professional, friendly, playful
Usage : structured, systematic, versatile, readable
Character : bold, impactful, sophisticated, warm, distinctive
The exact list of moods may change as new pairings are added to the registry. Always call getAllMoods() to get the current list.
getPairingsByMood Filter pairings by a specific mood tag
getAllPairings Get all available pairings
Notes
Moods are extracted from the mood array field of each pairing
The function deduplicates moods automatically using a Set
Returns an array of strings in no particular order
Empty array is returned only if no pairings exist (should never happen in production)
Performance: O(n × m) where n is number of pairings and m is average moods per pairing
Source Reference
Implementation: lib/pairings.ts:47-51