( tools: T[], sort: ToolSortOption )
| 30 | export type ToolSortOption = "featured" | "title"; |
| 31 | |
| 32 | export function sortTools<T extends RenderableTool>( |
| 33 | tools: T[], |
| 34 | sort: ToolSortOption |
| 35 | ): T[] { |
| 36 | return [...tools].sort((a, b) => { |
| 37 | if (sort === "featured") { |
| 38 | if (a.featured && !b.featured) return -1; |
| 39 | if (!a.featured && b.featured) return 1; |
| 40 | } |
| 41 | |
| 42 | return a.title.localeCompare(b.title); |
| 43 | }); |
| 44 | } |
| 45 | |
| 46 | function formatMultilineText(text: string): string { |
| 47 | return escapeHtml(text).replace(/\r?\n/g, "<br>"); |