Skip to content

Commit 3136e1b

Browse files
committed
add badges to category pages
1 parent 3c0b48d commit 3136e1b

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

apify-docs-theme/src/theme/custom.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,7 @@ iframe[src*="youtube"] {
16981698
justify-content: start;
16991699
}
17001700

1701+
.openapi-endpoint.api-method::before,
17011702
.api-method > .menu__link::before,
17021703
.schema > .menu__link::before {
17031704
width: 55px;
@@ -1726,73 +1727,88 @@ iframe[src*="youtube"] {
17261727
}
17271728

17281729
.get > .menu__link::before,
1730+
.openapi-endpoint.api-method.get::before,
17291731
.theme-api-markdown .openapi__method-endpoint .badge--primary {
17301732
background-color: var(--ifm-color-info-contrast-background);
17311733
color: var(--ifm-color-info-contrast-foreground);
17321734
border-color: var(--ifm-color-info-dark);
17331735
}
17341736

1737+
.openapi-endpoint.api-method.get::before,
17351738
.get > .menu__link::before {
17361739
content: 'get';
17371740
}
17381741

1742+
.openapi-endpoint.api-method.post::before,
17391743
.post > .menu__link::before {
17401744
content: 'post';
17411745
}
17421746

17431747
.post > .menu__link::before,
1748+
.openapi-endpoint.api-method.post::before,
17441749
.theme-api-markdown .openapi__method-endpoint .badge--success {
17451750
background-color: var(--ifm-color-success-contrast-background);
17461751
color: var(--ifm-color-success-contrast-foreground);
17471752
border-color: var(--ifm-color-success-dark);
17481753
}
17491754

1755+
.openapi-endpoint.api-method.delete::before,
17501756
.delete > .menu__link::before {
17511757
content: 'del';
17521758
}
17531759

17541760
.delete > .menu__link::before,
1761+
.openapi-endpoint.api-method.delete::before,
17551762
.theme-api-markdown .openapi__method-endpoint .badge--danger {
17561763
background-color: var(--ifm-color-danger-contrast-background);
17571764
color: var(--ifm-color-danger-contrast-foreground);
17581765
border-color: var(--ifm-color-danger-dark);
17591766
}
17601767

1768+
.openapi-endpoint.api-method.put::before,
17611769
.put > .menu__link::before {
17621770
content: 'put';
17631771
}
17641772

17651773
.put > .menu__link::before,
1774+
.openapi-endpoint.api-method.put::before,
17661775
.theme-api-markdown .openapi__method-endpoint .badge--info {
17671776
background-color: var(--ifm-color-warning-contrast-background);
17681777
color: var(--ifm-color-warning-contrast-foreground);
17691778
border-color: var(--ifm-color-warning-dark);
17701779
}
17711780

1781+
.openapi-endpoint.api-method.patch::before,
17721782
.patch > .menu__link::before {
17731783
content: 'patch';
17741784
}
17751785

17761786
.patch > .menu__link::before,
1787+
.openapi-endpoint.api-method.patch::before,
17771788
.theme-api-markdown .openapi__method-endpoint .badge--warning {
17781789
background-color: var(--ifm-color-success-contrast-background);
17791790
color: var(--ifm-color-success-contrast-foreground);
17801791
border-color: var(--ifm-color-success-dark);
17811792
}
17821793

1794+
.openapi-endpoint.api-method.head::before,
17831795
.head > .menu__link::before {
17841796
content: 'head';
17851797
}
17861798

17871799
.head > .menu__link::before,
1800+
.openapi-endpoint.api-method.head::before,
17881801
.event > .menu__link::before,
1802+
.openapi-endpoint.api-method.event::before,
17891803
.schema > .menu__link::before,
1804+
.openapi-endpoint.api-method.schema::before,
17901805
.theme-api-markdown .openapi__method-endpoint .badge--secondary {
17911806
background-color: var(--ifm-color-secondary-contrast-background);
17921807
color: var(--ifm-color-secondary-contrast-foreground);
17931808
border-color: var(--ifm-color-secondary-dark);
17941809
}
17951810

1811+
.openapi-endpoint.api-method.event::before,
17961812
.event > .menu__link::before {
17971813
content: 'event';
17981814
}

src/theme/DocCard/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function CardContainer({ href, children }) {
3535
);
3636
}
3737

38-
function CardLayout({ href, icon, title, description }) {
38+
function CardLayout({ href, icon, title, description, className }) {
3939
if (href.startsWith('/api')) {
4040
description = '';
4141
}
@@ -45,7 +45,7 @@ function CardLayout({ href, icon, title, description }) {
4545
href={href}>
4646
<Heading
4747
as="h2"
48-
className={clsx('text--truncate', styles.cardTitle)}
48+
className={clsx('text--truncate', styles.cardTitle, className)}
4949
title={title}>
5050
{icon} {title}
5151
</Heading>
@@ -78,8 +78,20 @@ function CardCategory({ item }) {
7878
}
7979

8080
function CardLink({ item }) {
81-
const icon = isInternalUrl(item.href) ? '📄️' : '🔗';
8281
const doc = useDocById(item.docId ?? undefined);
82+
83+
if (item.href.startsWith('/api/v2')) {
84+
return (
85+
<CardLayout
86+
href={item.href}
87+
title={item.label}
88+
className={clsx('openapi-endpoint', item.className)}
89+
description={item.description ?? doc?.description}
90+
/>
91+
);
92+
}
93+
94+
const icon = isInternalUrl(item.href) ? '📄️' : '🔗';
8395
return (
8496
<CardLayout
8597
href={item.href}

0 commit comments

Comments
 (0)