Skip to content

feat: option to use frontmatter ID as markdown filenames#22

Merged
rachfop merged 1 commit intorachfop:mainfrom
smol-ninja:feat/file-naming-using-frontmatter-id
Sep 25, 2025
Merged

feat: option to use frontmatter ID as markdown filenames#22
rachfop merged 1 commit intorachfop:mainfrom
smol-ninja:feat/file-naming-using-frontmatter-id

Conversation

@smol-ninja
Copy link
Copy Markdown
Contributor

@smol-ninja smol-ninja commented Sep 21, 2025

Closes #20

@svrnm, given that I am using this plugin in Sablier docs, and because this feature is very important for us, I decided to add this over the weekend (with the help of Claude).

I have kept the default behaviour unchanged. However, if useIdForFilenames is set to true, the filenames will use the frontmatter ID from the markdown files.

I've tested it on the Sablier docs and its working as expected. So, I would really appreciate if you could give it a review and merge the PR after you have agreed to the changes.

Since it's a new feature, should the next release be 0.3.0?

@smol-ninja
Copy link
Copy Markdown
Contributor Author

Also tagging @rachfop since you are the owner of the repo.

@PaulRBerg
Copy link
Copy Markdown

this feature would be tremendously helpful for our AI agentic workflows at Sablier

@svrnm
Copy link
Copy Markdown
Contributor

svrnm commented Sep 22, 2025

thanks @smol-ninja, would you mind testing what happens if someone has not defined an explicit ID (e.g. you quickly remove some of the ids in your repo and see what the generated file name is), because if it is actually picking up the implicit ID as outlined here: https://docusaurus.io/docs/create-doc#document-id I would vote for removing the useIdForFilenames and always do that instead of that code that is figuring out the filepath itself.

@smol-ninja
Copy link
Copy Markdown
Contributor Author

would you mind testing what happens if someone has not defined an explicit ID

In that case, it picks up the file name as usual.

would vote for removing the useIdForFilenames

Are you suggesting to make it a default behaviour i.e. if id is mentioned, use that for filename always?

@svrnm
Copy link
Copy Markdown
Contributor

svrnm commented Sep 22, 2025

Are you suggesting to make it a default behaviour i.e. if id is mentioned, use that for filename always?

Yes, based on the documentation from docusaurus, it sounds to me that there is always a DocumentID (https://docusaurus.io/docs/create-doc#document-id):

Every document has a unique id. By default, a document id is the name of the document (without the extension) relative to the root docs directory.

So if we can capture that ID somehow, then we have covered all the cases in one.

@smol-ninja
Copy link
Copy Markdown
Contributor Author

smol-ninja commented Sep 22, 2025

So if we can capture that ID somehow, then we have covered all the cases in one

Unfortunately, I could not find if Docusaurus offers an API to read that ID. So, I have added the following logic:

  1. Priority 1: use frontmatter's slug as file name (since its prioritised over doc ID)
  2. Priority 2: use frontmatter's id as file name
  3. Fallback to actual file name

The new tests cover all cases.

Let me know if it looks good: b28e843

@rachfop
Copy link
Copy Markdown
Owner

rachfop commented Sep 25, 2025

@smol-ninja thank you for the PR. This looks great.

@rachfop rachfop merged commit fa9c526 into rachfop:main Sep 25, 2025
@smol-ninja smol-ninja deleted the feat/file-naming-using-frontmatter-id branch September 25, 2025 19:07
@smol-ninja
Copy link
Copy Markdown
Contributor Author

Thanks for merging the PR. When will it be released?

@smol-ninja
Copy link
Copy Markdown
Contributor Author

Can we please cut a new release? We really need this.

@apollopy
Copy link
Copy Markdown

apollopy commented Nov 7, 2025

We also need this feature for our documentation. We're currently using docusaurus-plugin-llms@0.2.2 to generate llms.txt files for our SDK documentation.
The issue we're facing is that the current version generates URLs based on file paths instead of the slug values defined in our frontmatter. This results in incorrect URLs in the generated llms.txt file, as our documents use custom slug values to maintain clean, consistent URLs that differ from the actual file paths.
Could you please cut a new release with this feature? It would ensure that the generated URLs match the actual documentation URLs used in our Docusaurus site.
Thank you for your work on this plugin!

rachfop added a commit that referenced this pull request Feb 8, 2026
…tter-id

feat: option to use frontmatter ID as markdown filenames
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve original URL paths for markdown files instead of flattening them

5 participants