Skip to content

content-lint hard-codes the topic and audience slug lists that it can now import #185

Description

@hotlong

Observation from the #139 work (PR #182). Not a live defect — the two copies agree today. Filing it because the drift has never been drilled and the reason it existed is now gone.

What

scripts/content-lint.mjs validates post frontmatter against two literal sets:

const VALID_TOPIC = new Set([
  'ai-agents', 'app-building', 'integration-data', 'automation',
  'modernization', 'governance', 'customer-stories',
]);
const VALID_AUDIENCE = new Set(['business', 'it', 'developer', 'general']);

Both restate what src/lib/terms.ts already declares — slugsByGroup('topic') and slugsByGroup('role') — which is also what src/content.config.ts builds its z.enum from. Two producers of one fact.

The drift is one-directional and reaches an author, not a reviewer: add a topic to the taxonomy, use it in a post, and pnpm content:lint rejects the post with Invalid topic: <slug> while astro check and astro build are perfectly happy, because the Zod enum derives from the taxonomy and the lint set does not. The message points at the post, which is correct; the file to edit is the script.

Why now

The list was hard-coded because the script is plain Node and could not import src/lib/terms.ts (it value-imports extensionless ./i18n and ./zhconvert, which only Vite resolves). PR #182 removes that constraint: the taxonomy data now lives in src/lib/term-data.ts, a module with no imports, and content-lint.mjs already imports it to resolve topic hub links. Deriving both sets from RAW_TERMS is a few lines in a file the script already loads.

Notes for whoever takes it

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions