From 392b3fe90ec22fa837398ffe04a5c256dbba3c25 Mon Sep 17 00:00:00 2001 From: Gleb Voitenko Date: Thu, 21 Nov 2024 15:04:14 +0300 Subject: [PATCH] feat: add deprecated in Overview --- src/includer/ui/common.ts | 10 ++++++++-- src/includer/ui/section.ts | 10 +++++++++- src/runtime/index.scss | 8 ++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/includer/ui/common.ts b/src/includer/ui/common.ts index 8ab8dbc..7f535b9 100644 --- a/src/includer/ui/common.ts +++ b/src/includer/ui/common.ts @@ -28,8 +28,14 @@ function list(items: string[]) { return items.map((item) => `- ${item}`).join(EOL) + EOL; } -function link(text: string, src: string) { - return `[${text}](${src})`; +function link(text: string, src: string, className?: string) { + let md = `[${text}](${src})`; + + if (className) { + md += `{.${className}}`; + } + + return md; } function title(depth: TitleDepth) { diff --git a/src/includer/ui/section.ts b/src/includer/ui/section.ts index 25cf1af..0ae3092 100644 --- a/src/includer/ui/section.ts +++ b/src/includer/ui/section.ts @@ -20,7 +20,15 @@ function description(text?: string) { function endpoints(data?: V3Endpoints) { const visibleEndpoints = data?.filter((ep) => !ep.hidden); - const linkMap = ({id, summary}: V3Endpoint) => link(summary ?? id, id + '.md'); + const linkMap = ({id, summary, deprecated}: V3Endpoint) => { + let mdLink = link(summary ?? id, id + '.md', deprecated ? 'openapi-deprecated-link' : ''); + + if (deprecated) { + mdLink += ` `; + } + + return mdLink; + }; return ( visibleEndpoints?.length && diff --git a/src/runtime/index.scss b/src/runtime/index.scss index 1d3cafc..24c280c 100644 --- a/src/runtime/index.scss +++ b/src/runtime/index.scss @@ -189,3 +189,11 @@ [class^='openapi__response__code__'] > :last-child { margin-bottom: 15px; } + +a.openapi-deprecated-link { + text-decoration: line-through; + + & + svg { + opacity: 0.6; + } +}