Better ways of sorting & naming pages
See original GitHub issueHey, I’m enjoying nextra a lot, here’s a couple of nitpicks and things I’d like to suggest about sorting & naming.
Right now, order of entries meta.json
is what sets the order & title of the page. This means that I could name my pages like:
01-intro.mdx
02-getting-started.md
03-end.md
This also sorts them correctly in the editor and filesystems
They’d already be sorted alphabetically in the menu, but I’d still have to manually create a meta.json with the renames.
My proposal is, while leaving everything as is, adding the ability to rename via frontmatter, I noticed that I can use
---
title: Intro
---
to change the <title /> of the page, it would be convenient if this, or another key, were used to also set the name in the nav.
Thanks anyway for your time and kudos on the project!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Alphabetize or sort table data in Pages on Mac - Apple Support
In Pages on your Mac, sort data in a table alphabetically or by increasing or decreasing values. Create new sorting rules and delete...
Read more >Naming files by date for sorting - Tekmanagement -
Are you trying to organize and sort documents with dates in the title? The one thing you need to know to keep it...
Read more >Best Practices for File Naming and Organizing
FILE NAMING. A file name should enable disambiguation among similar files and, for large numbers of files that make up a dataset, facilitate...
Read more >Find Files Faster: How to Organize Files and Folders - Zapier
Start general then get specific: Since your filenames will naturally be sorted from whatever you type first, start with the most general ...
Read more >Creating a File Naming System: Tips to Organize Your Content
Use these tips to create a file naming system that allows you to locate all of your visual and written content easily.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the great suggestions! I agree with both of you that those can be improved.
Currently there’re some technical restrictions that I need to dig a little deeper. For the
meta.json
thing, what I’m thinking about is performance of I/O. Because every page renders the sidebar, which depends on name and order of all pages, so to render the sidebar we need to access:If we store that info (name and order of all pages) with frontmatter, we need to access the content of all files. I never did benchmarking but I believe that will become a performance issue when you have many many pages. Although I opened #34 for some related perf improvements, but it seems still very necessary to do some pressure testing. 😃
Regarding the customized
slug
, we need to bypass the restriction of Next.js that “route name === file name”, which isn’t that easy.Also personally I’m not a big fan of number based ordering (but I can see how good it organizes the files in the filesystem). Imagine that if want to insert/remove/reorder a page, you’ll have to rename many other files to make the numbers look good. With
meta.json
it’s much easier.As an alternative, could it make sense to define the pages order in the frontmatter of
index.mdx
?