-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(preprocess-auto-slug): complete docs page
- Loading branch information
Quang Phan
committed
Nov 21, 2022
1 parent
b2eaf2a
commit af949ec
Showing
37 changed files
with
600 additions
and
48 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 @@ | ||
--- | ||
'@svelte-put/preprocess-auto-slug': patch | ||
--- | ||
|
||
mature enough implementation with complelte docs page |
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
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
Binary file not shown.
69 changes: 68 additions & 1 deletion
69
apps/docs/src/routes/docs/(pkg)/preprocess-auto-slug/+page.svelte
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 |
---|---|---|
@@ -1 +1,68 @@ | ||
Documentation coming soon! | ||
<script lang="ts"> | ||
import suspiciousLinksImg from '$lib/assets/images/suspicious-links.webp'; | ||
import Code from '$lib/ui/components/Code/Code.svelte'; | ||
import Installation from '$lib/ui/components/Installation/Installation.svelte'; | ||
import ResourceLink from '$lib/ui/components/ResourceLink/ResourceLink.svelte'; | ||
import type { PageData } from './$types'; | ||
import { codes } from './codes'; | ||
export let data: PageData; | ||
</script> | ||
|
||
<section> | ||
<h2>Acknowledgement</h2> | ||
<p> | ||
This package is heavily inspired by | ||
<ResourceLink href="https://github.com/rehypejs/rehype-slug">rehype-slug</ResourceLink> | ||
and | ||
<ResourceLink href="https://github.com/rehypejs/rehype-autolink-headings"> | ||
rehype-autolink-headings | ||
</ResourceLink>. | ||
</p> | ||
</section> | ||
|
||
<Installation pkg={data.package.name} /> | ||
|
||
<section> | ||
<h2>Quick Start</h2> | ||
<Code lang="svelte" code={codes.quickStart} title="svelte.config.js" /> | ||
</section> | ||
|
||
<section> | ||
<h2>Customization</h2> | ||
|
||
<p> | ||
Almost every aspect of <code>preprocess-auto-slug</code> can be customized, including which tags | ||
to process, how <code>id</code> and <code>href</code> is generated, or the placement of the anchor | ||
tag. | ||
</p> | ||
<p> | ||
For more details, inspect in-code documentation, read the | ||
<ResourceLink href={data.package.apiUrl}>API Reference</ResourceLink>, and check out the | ||
<ResourceLink | ||
href="https://github.com/vnphanquang/svelte-put/blob/vercel/packages/preprocessors/auto-slug/src/auto-slug.constants.ts" | ||
>default options</ResourceLink | ||
>. | ||
</p> | ||
|
||
<p> | ||
This documentation site uses this very package. Most <code>id</code> | ||
and link tag for headings are auto-generated during build. See <ResourceLink | ||
href="https://github.com/vnphanquang/svelte-put/blob/vercel/apps/docs/svelte.config.js" | ||
>svelte.config.js</ResourceLink | ||
> | ||
as an example for a more complex use case. | ||
</p> | ||
</section> | ||
|
||
<img | ||
src={suspiciousLinksImg} | ||
alt="mouse click faster" | ||
width="300" | ||
height="168" | ||
loading="lazy" | ||
decoding="async" | ||
/> | ||
|
||
<p>Happy slugging! 👨💻</p> |
5 changes: 5 additions & 0 deletions
5
apps/docs/src/routes/docs/(pkg)/preprocess-auto-slug/codes/index.ts
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 @@ | ||
import quickStart from './quickStart.js?raw'; | ||
|
||
export const codes = { | ||
quickStart, | ||
}; |
8 changes: 8 additions & 0 deletions
8
apps/docs/src/routes/docs/(pkg)/preprocess-auto-slug/codes/quickStart.js
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,8 @@ | ||
import autoSlug from '@svelte-put/preprocess-auto-slug'; | ||
|
||
/** @type {import('@sveltejs/kit').Config} */ | ||
const config = { | ||
preprocess: [autoSlug()], | ||
}; | ||
|
||
export default config; |
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
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,6 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"extends": "@svelte-put/apirc/base.json", | ||
"projectFolder": ".", | ||
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts" | ||
} |
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,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) | ||
|
||
## API Reference | ||
|
||
## Packages | ||
|
||
| Package | Description | | ||
| ------------------------------------------------------------- | ----------- | | ||
| [@svelte-put/preprocess-auto-slug](./preprocess-auto-slug.md) | | |
27 changes: 27 additions & 0 deletions
27
packages/preprocessors/auto-slug/api/docs/preprocess-auto-slug.autoslug.md
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,27 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@svelte-put/preprocess-auto-slug](./preprocess-auto-slug.md) > [autoSlug](./preprocess-auto-slug.autoslug.md) | ||
|
||
## autoSlug() function | ||
|
||
create svelte preprocessor to generate slug from text content of matching tags | ||
|
||
By default, it will search for all headings tag and add the generated slug to the tag's id attribute. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
declare function autoSlug(input?: AutoSlugInput): PreprocessorGroup; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --------- | -------------------------------------------------------- | ----------------- | | ||
| input | [AutoSlugInput](./preprocess-auto-slug.autosluginput.md) | <i>(Optional)</i> | | ||
|
||
<b>Returns:</b> | ||
|
||
PreprocessorGroup | ||
|
||
svelte preprocessor interface |
13 changes: 13 additions & 0 deletions
13
...essors/auto-slug/api/docs/preprocess-auto-slug.autosluganchoroptions.content.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@svelte-put/preprocess-auto-slug](./preprocess-auto-slug.md) > [AutoSlugAnchorOptions](./preprocess-auto-slug.autosluganchoroptions.md) > [content](./preprocess-auto-slug.autosluganchoroptions.content.md) | ||
|
||
## AutoSlugAnchorOptions.content property | ||
|
||
content of the inserted anchor tag, ignored when behavior is `wrap`<!-- -->. Default to '\#' | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
content: string; | ||
``` |
13 changes: 13 additions & 0 deletions
13
...essors/auto-slug/api/docs/preprocess-auto-slug.autosluganchoroptions.enabled.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@svelte-put/preprocess-auto-slug](./preprocess-auto-slug.md) > [AutoSlugAnchorOptions](./preprocess-auto-slug.autosluganchoroptions.md) > [enabled](./preprocess-auto-slug.autosluganchoroptions.enabled.md) | ||
|
||
## AutoSlugAnchorOptions.enabled property | ||
|
||
whether to insert an anchor tag for each matching node | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
enabled: boolean; | ||
``` |
13 changes: 13 additions & 0 deletions
13
...rocessors/auto-slug/api/docs/preprocess-auto-slug.autosluganchoroptions.href.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@svelte-put/preprocess-auto-slug](./preprocess-auto-slug.md) > [AutoSlugAnchorOptions](./preprocess-auto-slug.autosluganchoroptions.md) > [href](./preprocess-auto-slug.autosluganchoroptions.href.md) | ||
|
||
## AutoSlugAnchorOptions.href property | ||
|
||
href attribute of the inserted anchor tag | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
href: (slug: string) => string; | ||
``` |
23 changes: 23 additions & 0 deletions
23
.../preprocessors/auto-slug/api/docs/preprocess-auto-slug.autosluganchoroptions.md
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,23 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@svelte-put/preprocess-auto-slug](./preprocess-auto-slug.md) > [AutoSlugAnchorOptions](./preprocess-auto-slug.autosluganchoroptions.md) | ||
|
||
## AutoSlugAnchorOptions interface | ||
|
||
instructions for adding anchor tag | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
interface AutoSlugAnchorOptions | ||
``` | ||
|
||
## Properties | ||
|
||
| Property | Modifiers | Type | Description | | ||
| ------------------------------------------------------------------------ | --------- | ------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| [content](./preprocess-auto-slug.autosluganchoroptions.content.md) | | string | content of the inserted anchor tag, ignored when behavior is <code>wrap</code>. Default to '\#' | | ||
| [enabled](./preprocess-auto-slug.autosluganchoroptions.enabled.md) | | boolean | whether to insert an anchor tag for each matching node | | ||
| [href](./preprocess-auto-slug.autosluganchoroptions.href.md) | | (slug: string) => string | href attribute of the inserted anchor tag | | ||
| [position](./preprocess-auto-slug.autosluganchoroptions.position.md) | | 'prepend' \| 'append' \| 'wrap' \| 'before' \| 'after' | <p>where to create the anchor tag</p><p>- 'prepend' — inject link before the target tag text</p><p>- 'append' — inject link after the target tag text</p><p>- 'wrap' — wrap the whole target tag text with the link</p><p>- 'before' — insert link before the target tag</p><p>- 'after' — insert link after the target tag</p><p>default to <code>prepend</code></p> | | ||
| [properties](./preprocess-auto-slug.autosluganchoroptions.properties.md) | | Record<string, string> | properties set to the inserted anchor tag, defaults to <code>{ 'aria-hidden': 'true', 'tab-index': '-1' }</code> | |
25 changes: 25 additions & 0 deletions
25
...ssors/auto-slug/api/docs/preprocess-auto-slug.autosluganchoroptions.position.md
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,25 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@svelte-put/preprocess-auto-slug](./preprocess-auto-slug.md) > [AutoSlugAnchorOptions](./preprocess-auto-slug.autosluganchoroptions.md) > [position](./preprocess-auto-slug.autosluganchoroptions.position.md) | ||
|
||
## AutoSlugAnchorOptions.position property | ||
|
||
where to create the anchor tag | ||
|
||
- 'prepend' — inject link before the target tag text | ||
|
||
- 'append' — inject link after the target tag text | ||
|
||
- 'wrap' — wrap the whole target tag text with the link | ||
|
||
- 'before' — insert link before the target tag | ||
|
||
- 'after' — insert link after the target tag | ||
|
||
default to `prepend` | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
position: 'prepend' | 'append' | 'wrap' | 'before' | 'after'; | ||
``` |
13 changes: 13 additions & 0 deletions
13
...ors/auto-slug/api/docs/preprocess-auto-slug.autosluganchoroptions.properties.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@svelte-put/preprocess-auto-slug](./preprocess-auto-slug.md) > [AutoSlugAnchorOptions](./preprocess-auto-slug.autosluganchoroptions.md) > [properties](./preprocess-auto-slug.autosluganchoroptions.properties.md) | ||
|
||
## AutoSlugAnchorOptions.properties property | ||
|
||
properties set to the inserted anchor tag, defaults to `{ 'aria-hidden': 'true', 'tab-index': '-1' }` | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
properties: Record<string, string>; | ||
``` |
Oops, something went wrong.