#Custom slug without overriding path in content collections

3 messages · Page 1 of 1 (latest)

sullen storm
#

I'm using Startlight to create docs, and I love it so far, thanks for maintaining it!

I want to have source files using the following naming convention so they appear in the explorer in the same order as they appear on the docs themselves

thib@MacBook content % tree
.
├── config.ts
└── docs
    ├── deployment
    │   ├── dependencies.md
    │   └── provisioning.md
    ├── index.mdx
    ├── learning
    │   ├── 10-ssh-and-fingerprints.md
    │   ├── 15-ansible.md
    │   ├── 20-containers.md
    │   ├── 30-traefik.md
    │   ├── 40-firewalld.md
    │   ├── 50-systemd.md
    │   └── 60-wireguard.md
    └── overview
        ├── 10-what-is-it.md
        └── 20-technical-overview.md

I'm currently using the slug frontmatter property to get rid of the xx- prefix, but I need to add the directory in the slug (e.g. learning/ssh-and-fingerprints).

Is it possible to keep autogenerating a slug but to strip the xx- prefix?

Alternatives considered: using the sidebar.order frontmatter property and stripping the xx- from the filenames themselves, but in this case the files explorer doesn't display the files in the same order as the docs

gusty mangoBOT
#
No-one around right now?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.

median forum
#

Hey @sullen storm! No, that’s not supported currently, sorry — the frontmatter slug approach is probably the only one that works for now.

We could think about some method for customising slugs programmatically perhaps, so you could specify your logic for stripping certain parts of the filename, but in general we do like to stick as much as possible to file-based routing for the simplicity it brings of file path == URL pathname.