The default "remark-toc" plugin may not generate a TOC for markdown files that are imported as Svelte components. To address this limitation, you can use a built-in function provided by the "mdx-svelte" package.
Example usage
+layout.svelte:
Returns:
WARNING
When using this solution, remember to disable the "remark-toc" plugin.