Astro adapter
Extract prose from .astro files.
@faircopy/astro extracts prose from .astro files. It parses each file with @astrojs/compiler, walks the AST, and emits text nodes plus any frontmatter string identifiers you flag as prose.
Install
npm install -D @faircopy/astro
Usage
import { astro } from '@faircopy/astro'
import { defineConfig } from '@faircopy/config'
export default defineConfig({
files: ['src/**/*.astro'],
adapters: [astro()],
rules: {
'no-em-dash': 'error',
'no-weasel-words': 'error',
'no-rhetorical-scaffolding': 'error',
},
})
What gets extracted
- Text nodes inside any element except
<script>,<style>,<code>,<pre>,<kbd> - Frontmatter string literals whose const identifier matches a prose name (
title,description,subtitle,tagline,lede,metaDescription,ogTitle,ogDescription,heading)
Options
astro({
proseIdentifiers: ['heroHeadline', 'ctaLabel'], // extra frontmatter identifiers
lintAttributes: { attributes: ['alt', 'aria-label'] }, // lint attribute values
lintExpressionStrings: true, // lint { 'string literals' } in JSX expressions
})
Ignoring sections
Add data-faircopy-ignore to any element and its subtree skips linting.
<div data-faircopy-ignore>
<p>This paragraph won't be linted — even with an em-dash.</p>
</div>