Files
davideisinger.com/content/journal/spellcheck-your-hugo-site-with-cspell/index.md
2024-11-20 16:13:01 -05:00

1.5 KiB

title, date, draft, tags
title date draft tags
Spellcheck Your Hugo Site With CSpell 2024-11-20T09:49:51-05:00 false
meta

Bla bla bla

1. Install CSpell

2. Add config file

3. Ignore frontmatter

4. Ignore proper nouns

5. Fix spelling

6. Create custom dictionary

7. Add to build pipeline


Here's the final .cspell.json config file.

{
  "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
  "version": "0.2",
  "dictionaryDefinitions": [
    {
      "name": "exceptions",
      "path": ".dictionary",
      "addWords": true
    }
  ],
  "dictionaries": [
    "english",
    "ruby",
    "golang",
    "exceptions"
  ],
  "patterns": [
    {
      "name": "frontmatter",
      "pattern": "/^(-{3}|[+]{3})$(\\s|\\S)*?^\\1$/gm"
    },
    {
      "name": "proper_nouns",
      "pattern": "/[\\W_][A-Z][\\S]+/g"
    }
  ],
  "languageSettings": [
    {
      "languageId": "markdown",
      "ignoreRegExpList": [
        "frontmatter",
        "proper_nouns"
      ]
    }
  ]
}
npx cspell content/**/*.md
npx cspell --words-only --unique content/**/*.md >> .dictionary
sort -o .dictionary .dictionary