-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from trueberryless-org/docs
Write documentation
- Loading branch information
Showing
34 changed files
with
1,445 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"starlight-spell-checker-docs": minor | ||
--- | ||
|
||
Write initial documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
title: Conditional Validation | ||
description: Learn how to run the Starlight Spell Checker plugin conditionally to avoid unnecessary cache invalidation. | ||
--- | ||
|
||
When using the Starlight Spell Checker plugin with the [Content Layer API](https://docs.astro.build/en/guides/content-collections), the plugin will automatically invalidate the content layer cache so that all words can be properly validated. | ||
To avoid unnecessary cache invalidation, it is recommended to conditionally use the plugin only when necessary. | ||
|
||
## Run the plugin conditionally | ||
|
||
By default, when adding the plugin to your Starlight configuration in the [`plugins`](https://starlight.astro.build/reference/configuration/#plugins) array, the plugin will run for every build. | ||
|
||
Instead of running the plugin for every build, you can conditionally use the plugin based on an environment variable. | ||
In the following example, the plugin will only run when the `CHECK_SPELLING` environment variable is set. | ||
|
||
```diff lang="js" | ||
// astro.config.mjs | ||
import starlight from '@astrojs/starlight' | ||
import { defineConfig } from 'astro/config' | ||
import starlightSpellChecker from 'starlight-spell-checker' | ||
|
||
export default defineConfig({ | ||
integrations: [ | ||
starlight({ | ||
- plugins: [starlightSpellChecker()], | ||
+ plugins: process.env.CHECK_SPELLING ? [starlightSpellChecker()] : [], | ||
title: 'My Docs', | ||
}), | ||
], | ||
}) | ||
``` | ||
|
||
To run the plugin only when the `CHECK_SPELLING` environment variable is set, you can add the following script to your `package.json` file: | ||
|
||
```json title="package.json" | ||
{ | ||
"scripts": { | ||
"spellcheck": "CHECK_SPELLING=true astro build" | ||
} | ||
} | ||
``` | ||
|
||
The spell check script can be used on CI pipelines to validate internal words in a dedicated workflow while deployment builds can skip the link validation step. |
Oops, something went wrong.