Order pages by final stub

Hi

Probably a relatively simple question but I’m struggling to find the relevant attribute if it exists.

I have a load of pages which are named something like this:

  • Anniversary
  • Gluster
  • Syncthing
  • BTLO
  • BTLO/Challenges
  • BTLO/Challenges/ATT&CK
  • BTLO/Investigations
  • BTLO/Investigations/Stalker

When I do a page query and set order by name everything starting BTLO is ordered by that rather than the final stub (eg Stalker)

Is there a way to order by the final stub? Or should I set displayName in the frontmatter and order by that?

Similarly is there a way to exclude pages which contain / in the name?

Obviously I could use tags on the pages I want to appear in the list as well, I just naturally liked the idea of using the foldered structure to the naming.

Thanks in advance for any advice!

It’s a bit ugly and costly, but you can do this with a replace and a regex that removes the folder part:

For instance:

```query
page order by replace(name, /(.*?)([^\/]+$)/, "$2") limit 5
```

If you’d like to omit any pages that contain a / you can do

```query
page where not contains(name, "/")
```

Thanks, I think I’ll likely use the second option for now but good to know that regex is an option.