diff --git a/.changeset/tall-jobs-wait.md b/.changeset/tall-jobs-wait.md new file mode 100644 index 0000000000..3f54711a5a --- /dev/null +++ b/.changeset/tall-jobs-wait.md @@ -0,0 +1,5 @@ +--- +"@skeletonlabs/skeleton": patch +--- + +chore: Update Table of Contents to include optional `prefix` and `suffix` parameters diff --git a/packages/skeleton/src/lib/utilities/TableOfContents/crawler.ts b/packages/skeleton/src/lib/utilities/TableOfContents/crawler.ts index 996f1c3f5c..dfee9b4c52 100644 --- a/packages/skeleton/src/lib/utilities/TableOfContents/crawler.ts +++ b/packages/skeleton/src/lib/utilities/TableOfContents/crawler.ts @@ -12,6 +12,10 @@ interface TOCCrawlerArgs { scrollTarget?: string; /** Reload the action when this key value changes. */ key?: unknown; + /* Provide a prefix for ToC links, to help keep them unique. */ + prefix?: string; + /* Provide a suffix for ToC links, to help keep them unique. */ + suffix?: string; } export function tocCrawler(node: HTMLElement, args?: TOCCrawlerArgs) { @@ -44,7 +48,9 @@ export function tocCrawler(node: HTMLElement, args?: TOCCrawlerArgs) { .replaceAll(/[^a-zA-Z0-9 ]/g, '') .replaceAll(' ', '-') .toLowerCase(); - elemHeading.id = `toc-${newHeadingId}`; + const prefix = args.prefix ? `${args.prefix}-` : ''; + const suffix = args.suffix ? `-${args.suffix}` : ''; + elemHeading.id = prefix + newHeadingId + suffix; } // Push heading data to the permalink array permalinks.push({ diff --git a/sites/skeleton.dev/src/routes/(inner)/elements/chat/+page.svelte b/sites/skeleton.dev/src/routes/(inner)/elements/chat/+page.svelte index 9ec67b5b85..695933a08e 100644 --- a/sites/skeleton.dev/src/routes/(inner)/elements/chat/+page.svelte +++ b/sites/skeleton.dev/src/routes/(inner)/elements/chat/+page.svelte @@ -473,7 +473,8 @@ let messageFeed = [
-

Prompt

+ +

Prompt

We can utilize a Skeleton Input Group to create a custom text prompt.

diff --git a/sites/skeleton.dev/src/routes/(inner)/utilities/table-of-contents/+page.svelte b/sites/skeleton.dev/src/routes/(inner)/utilities/table-of-contents/+page.svelte index 52b2d76217..0c5e377091 100644 --- a/sites/skeleton.dev/src/routes/(inner)/utilities/table-of-contents/+page.svelte +++ b/sites/skeleton.dev/src/routes/(inner)/utilities/table-of-contents/+page.svelte @@ -79,10 +79,24 @@ code={`

Title One

-

Title Two

\n +

Title Two

\n

Title One

Title Two

+ `} + /> + +

Prefixes and Suffixes

+ +

+ We recommend setting a custom heading (per the instruction above) if a conflict is found within your page. However, you may also hardcode a prefix or suffix to all generated IDs as follows: +

+ \n + + `} />