pull/662/head
Zef Hemel 2024-01-24 14:52:07 +01:00
parent 8a89d69c22
commit 308b1232bc
1 changed files with 34 additions and 20 deletions

View File

@ -44,26 +44,40 @@ export function PageNavigator({
if (isFederationPath(pageMeta.name)) { if (isFederationPath(pageMeta.name)) {
orderId = Math.round(orderId / 10); // Just 10x lower the timestamp to push them down, should work orderId = Math.round(orderId / 10); // Just 10x lower the timestamp to push them down, should work
} }
let description: string | undefined;
let aliases: string[] = []; if (mode === "page") {
if (pageMeta.displayName) { // Special behavior for regular pages
aliases.push(pageMeta.displayName); let description: string | undefined;
let aliases: string[] = [];
if (pageMeta.displayName) {
aliases.push(pageMeta.displayName);
}
if (Array.isArray(pageMeta.aliases)) {
aliases = aliases.concat(pageMeta.aliases);
}
if (aliases.length > 0) {
description = "(a.k.a. " + aliases.join(", ") + ") ";
}
if (pageMeta.tags) {
description = (description || "") +
pageMeta.tags.map((tag) => `#${tag}`).join(" ");
}
options.push({
...pageMeta,
description,
orderId: orderId,
});
} else {
// Special behavior for templates
options.push({
...pageMeta,
// Use the displayName or last bit of the path as the name
name: pageMeta.displayName || pageMeta.name.split("/").pop()!,
// And use the full path as the description
description: pageMeta.name,
orderId: orderId,
});
} }
if (Array.isArray(pageMeta.aliases)) {
aliases = aliases.concat(pageMeta.aliases);
}
if (aliases.length > 0) {
description = "(a.k.a. " + aliases.join(", ") + ") ";
}
if (pageMeta.tags) {
description = (description || "") +
pageMeta.tags.map((tag) => `#${tag}`).join(" ");
}
options.push({
...pageMeta,
description,
orderId: orderId,
});
} }
let completePrefix = currentPage + "/"; let completePrefix = currentPage + "/";
if (currentPage && currentPage.includes("/")) { if (currentPage && currentPage.includes("/")) {
@ -116,7 +130,7 @@ export function PageNavigator({
newHint={`Create ${mode}`} newHint={`Create ${mode}`}
completePrefix={completePrefix} completePrefix={completePrefix}
onSelect={(opt) => { onSelect={(opt) => {
onNavigate(opt?.name); onNavigate(opt?.ref);
}} }}
/> />
); );