Returns all NodeData entries where frontMatter[key] === value. Useful for building tag pages, filtering by category, or any frontmatter-driven grouping.

import { getNodesByFrontMatter } from 'slugtree'

const guides = getNodesByFrontMatter('category', 'guide')
const featured = getNodesByFrontMatter('featured', true)

Parameters

ParameterTypeDescription
keystringThe frontmatter field name to match against.
valueunknownThe value to compare using strict equality (===).

Return value

Returns NodeData[] where every entry has frontMatter[key] === value.

Usage

The key accepts any string and is matched against the raw frontmatter object, so you can use custom fields beyond the built-in title, description, and icon:

---
title: Advanced Routing
category: guide
featured: true
---
import { getNodesByFrontMatter } from 'slugtree'

const featuredGuides = getNodesByFrontMatter('category', 'guide').filter(
  (n) => n.frontMatter.featured === true
)

For more complex conditions — multiple fields, computed values, content matching — use findNodes() instead.