Route guide
Nova replaces the traditional eggids
/nestids
system with route conditions.
To get started with route conditions, locate and uncomment this import at the top of the file:
// [*] Uncomment the import below if you want to use conditions!
// import { isNest, isEgg, and, or } from '@/lib/nova/conditions';
How to use them?
Typically, whenever you're instructed to add a line such as:
eggids: [12, 34],
eggid: 12,
You instead can add:
condition: isEgg(12, 34),
condition: isEgg(12),
The same is true for nests. Instead of adding nestid
/nestids
, use isNest(...)
.
If you want to combine multiple conditions together, it's very easy to do so. For example, to show a route only on servers with a nest ID of 1 and an egg ID of 2:
condition: and(isNest(1), isEgg(2)),
Likewise, to show a route on servers with a nest ID of 1 or with an egg ID of 2:
condition: or(isNest(1), isEgg(2)),
How do I add a header to the sidebar?
If you want to add a header between the routes, add a route entry like this:
{
header: true,
content: "My header",
}
This will work only in the server routes block.
You can add conditions to headers the same way as you do with normal routes.
Custom conditions
If you want to create your own conditions, it is very easy to do so. Conditions are functions that take in no arguments and which return a boolean.
You can use any React hooks in a condition. For example, to show a route only on servers whose name starts with an 'A', you could use the following condition:
const onlyAs = () =>
ServerContext.useStoreState((state) => state.server.data?.name)?.startsWith(
"A",
) ?? false;
Then you can add this condition onto any route:
condition: onlyAs,