Skip to content

Commit abb54f6

Browse files
committed
feat(preprocess-auto-slug): allow skipping per file with ignore comment
1 parent dbeecf8 commit abb54f6

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

.changeset/sour-drinks-behave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@svelte-put/preprocess-auto-slug': patch
3+
---
4+
5+
allow skipping processing with `<!-- ignore @svelte-put/preprocess-auto-slug -->`

packages/preprocessors/auto-slug/api/docs/preprocess-auto-slug.autoslugoptions.files.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ filter which files the preprocessor will run on
1111
```typescript
1212
files: (options: Parameters<MarkupPreprocessor>[0]) => boolean;
1313
```
14+
15+
## Remarks
16+
17+
Alternatively, you can skip processing per file by adding `<!-- ignore @svelte-put/preprocess-auto-slug -->` somewhere in the file.
18+

packages/preprocessors/auto-slug/src/auto-slug.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export function autoSlug(input: AutoSlugInput = {}): PreprocessorGroup {
3232
markup(o) {
3333
const { content, filename } = o;
3434
if (!options.files(o)) return;
35+
if (content.includes('<!-- ignore @svelte-put/preprocess-auto-slug -->')) return;
3536
const s = new MagicString(content);
3637
const ast = parse(content, { filename });
3738
const slugger = new BananaSlug();

packages/preprocessors/auto-slug/src/auto-slug.types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ export interface SlugResolverInput {
7474
export interface AutoSlugOptions {
7575
/**
7676
* filter which files the preprocessor will run on
77+
*
78+
* @remarks
79+
*
80+
* Alternatively, you can skip processing per file by adding
81+
* `<!-- ignore @svelte-put/preprocess-auto-slug -->` somewhere in the file.
7782
*/
7883
files: (options: Parameters<MarkupPreprocessor>[0]) => boolean;
7984
/** target tag, default to all heading tags */

0 commit comments

Comments
 (0)