question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better ways of sorting & naming pages

See original GitHub issue

Hey, 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
shudingcommented, Dec 17, 2020

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:

  1. structure of the filesystem (recursively readdir)
  2. content of all meta.json files (a couple of readfile)

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.

3reactions
Janpotcommented, Apr 14, 2021

As an alternative, could it make sense to define the pages order in the frontmatter of index.mdx?

---
order:
- introduction
- installation
- getting-started
- ...
---
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found