Skip to content

Commit

Permalink
docs: created page listing Harper's rules
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-potter committed Dec 31, 2024
1 parent 5f98d68 commit 6616712
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/web/src/routes/docs/rules/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script module lang="ts">
import { LocalLinter } from 'harper.js';
export const prerender = true;
export const frontmatter = {
title: 'Rules'
};
let info: Record<string, string> = $state({});
let titles: Record<string, string> = $state({});
let linter = new LocalLinter();
linter.getLintDescriptions().then(async (v) => {
info = v;
for (let key of Object.keys(info)) {
titles[key] = await makeTitleCase(key);
console.log(key, titles[key]);
}
});
/** Make a snake case string title case. */
function makeTitleCase(snakeCase: string): Promise<string> {
return linter.toTitleCase(snakeCase.replaceAll('_', ' '));
}
</script>

<p>This page is an incomplete list of the various grammatical rules Harper checks for.</p>

{#each Object.entries(info) as [name, description]}
<h2>{titles[name]}</h2>
<p>{description}</p>
<p>This rule is also often referred to as <code>{name}</code>.</p>
{/each}
4 changes: 4 additions & 0 deletions packages/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export default defineConfig({
to: '/docs/contributors/architecture'
}
]
},
{
title: 'Rules',
to: '/docs/rules'
}
]
},
Expand Down

0 comments on commit 6616712

Please sign in to comment.