Skip to content

Commit

Permalink
feat: add deprecated in Overview
Browse files Browse the repository at this point in the history
  • Loading branch information
v8tenko committed Nov 21, 2024
1 parent d409f93 commit 392b3fe
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/includer/ui/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 9 additions & 1 deletion src/includer/ui/section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 += ` <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M11.323 12.383a5.5 5.5 0 0 1-7.706-7.706zm1.06-1.06L4.677 3.617a5.5 5.5 0 0 1 7.706 7.706M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0" clip-rule="evenodd"/></svg>`;
}

return mdLink;
};

return (
visibleEndpoints?.length &&
Expand Down
8 changes: 8 additions & 0 deletions src/runtime/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 392b3fe

Please sign in to comment.