The links menu moves into @hive/shared and takes its links as a prop. The swarm UI feeds it /api/links as before; the dashboard feeds it stats, API docs and the swarm, and mounts it next to the profile menu in place of its own hamburger on the left. A link opens in a new tab unless its entry says it is a page of the same site.
25 lines
868 B
TypeScript
25 lines
868 B
TypeScript
// What the links menu shows for one link, without a DOM: where it opens and
|
|
// what it is called. Shared by the swarm UI (its `/api/links`) and the hive
|
|
// dashboard (its stats and API docs pages, and the swarm UI).
|
|
|
|
/** One entry of the links menu. */
|
|
export interface MenuLink {
|
|
label: string;
|
|
/** A glyph before the label; none leaves the label alone. */
|
|
icon?: string;
|
|
url: string;
|
|
/**
|
|
* Opens in a new tab. Defaults to true: a link the menu was handed from
|
|
* elsewhere (the swarm's service list) leaves the page. A page of the
|
|
* same site says `false` and opens in place.
|
|
*/
|
|
external?: boolean;
|
|
}
|
|
|
|
/** The anchor attributes that make a link open where its entry says. */
|
|
export function linkAttrs(link: MenuLink): {
|
|
target?: string;
|
|
rel?: string;
|
|
} {
|
|
return link.external === false ? {} : { target: "_blank", rel: "noreferrer" };
|
|
}
|