Coder Social home page Coder Social logo

Comments (4)

janosh avatar janosh commented on May 20, 2024

Don't remember deactivating the discussions tab but it's back now.

Thanks for the describing your use case! This feature sounds like it's out of scope for svelte-toc though. If the goal is to render anchors for each heading like on the demo site for this component:

Screen Shot 2022-09-14 at 08 05 21

then my advice would be to use a markdown/HTML parser that allows customizing the output based on tag. This site uses
mdsvex with plugins rehype-autolink-headings and rehype-slug in svelte.config.js to do this:

import { mdsvex } from 'mdsvex'
import linkHeadings from 'rehype-autolink-headings'
import headingSlugs from 'rehype-slug'
import preprocess from 'svelte-preprocess'
const rehypePlugins = [
headingSlugs,
[
linkHeadings,
{
behavior: `append`,
test: [`h2`, `h3`, `h4`, `h5`, `h6`], // don't auto-link <h1>
content: s(
`svg`,
{ width: 16, height: 16, viewBox: `0 0 16 16` },
// symbol #octicon-link defined in app.html
s(`use`, { 'xlink:href': `#octicon-link` })
),
},
],
]
export default {
extensions: [`.svelte`, `.svx`, `.md`],
preprocess: [
preprocess(),
mdsvex({ rehypePlugins, extensions: [`.svx`, `.md`] }),

from svelte-toc.

oskar-gmerek avatar oskar-gmerek commented on May 20, 2024

Thanks, @janosh.
I was think that was breaking the bank, as the rehype has a plugin doing exactly what I need, but unfortunately is broken and not maintained. I need it for animations, so the rehype-slug will be close, but not enough.

Anyway thanks a lot!

BTW. Is it possible to detect in someway when ToC is turning to be fixed position? My use case is on top of my content currently and can't find a way to move it out at the exact time.

from svelte-toc.

janosh avatar janosh commented on May 20, 2024

BTW. Is it possible to detect in someway when ToC is turning to be fixed position? My use case is on top of my content currently and can't find a way to move it out at the exact time.

Maybe this helps? https://css-tricks.com/how-to-detect-when-a-sticky-element-gets-pinned

from svelte-toc.

oskar-gmerek avatar oskar-gmerek commented on May 20, 2024

https://css-tricks.com/how-to-detect-when-a-sticky-element-gets-pinned

Thanks again!

from svelte-toc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.