Skip to content

Commit

Permalink
chore: clean up cspell
Browse files Browse the repository at this point in the history
  • Loading branch information
uncenter committed Aug 14, 2023
1 parent 3d67d9e commit 91a74ca
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 69 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"scripts": {
"dev": "eleventy --serve",
"clean": "rimraf dist/ .cache",
"spell": "node ./utils/update-dicts.js && cspell src/posts/**/*.md",
"spell": "cspell src/posts/**/*.md",
"format": "prettier --write .",
"build": "eleventy"
},
Expand Down
35 changes: 14 additions & 21 deletions src/posts/spellchecking-with-eleventy.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,10 @@ An important step is to define specific words to exclude or flag. I told `cSpell

```js
words: [
// Eleventy
'eleventy',
'11ty',
'shortcode',
'shortcodes',
'pagination',
'webc',

// Misc
'dotfiles',
'janky',
],
flagWords: [],
```
Expand All @@ -81,27 +75,26 @@ Instead of manually updating my `repos.txt` dict, I wrote a script to fetch my r
```js
#!/usr/bin/env node

const fs = require('fs');
const path = require('path');

function getRepos() {
const reposFile = path.join(__dirname, './dicts/repos.txt');
const reposURL = 'https://api.github.com/users/uncenter/repos';
const fs = require('node:fs/promises');
const { join } = require('node:path');

(async () => {
const response = await fetch(reposURL);
async function getRepos() {
try {
const response = await fetch('https://api.github.com/users/uncenter/repos');
const json = await response.json();

if (Array.isArray(json)) {
const repos = json.map((repo) => repo.name);
fs.writeFileSync(reposFile, repos.join('\n'));
fs.writeFile(
join(__dirname, './dicts/repos.txt'),
json.map((repo) => repo.name).join('\n'),
);
} else {
console.log('Invalid response format:', json);
throw new TypeError('Invalid response content.');
}
})();
} catch {
console.error('[cspell:update] Something went wrong.');
}
}

getRepos();
```

If you're using Netlify, you can run this script and the spell-check script during the build process by adding it to the `build` command in your `netlify.toml` file (or the GUI on Netlify's website):
Expand Down
24 changes: 0 additions & 24 deletions utils/dicts/repos.txt

This file was deleted.

23 changes: 0 additions & 23 deletions utils/update-dicts.js

This file was deleted.

0 comments on commit 91a74ca

Please sign in to comment.