Skip to content

Commit 4495038

Browse files
author
shuai
committed
fix: quick-links update
1 parent ba8a24d commit 4495038

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

quick-links/Component.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,31 @@
1717
* under the License.
1818
*/
1919

20+
import React from 'react';
2021
import { useTranslation } from 'react-i18next';
2122
import useSWR from 'swr'
2223

23-
const Component = ({ navigate, request, hasDivider }) => {
24+
interface Tag {
25+
slug_name: string;
26+
display_name: string;
27+
}
28+
29+
interface SidebarConfigData {
30+
tags?: Tag[];
31+
links_text?: string;
32+
}
33+
34+
interface ComponentProps {
35+
navigate: (url: string) => void;
36+
request: {
37+
instance: {
38+
get: (url: string) => Promise<SidebarConfigData>;
39+
};
40+
};
41+
hasDivider?: boolean;
42+
}
43+
44+
const Component = ({ navigate, request, hasDivider }: ComponentProps) => {
2445

2546
const { t } = useTranslation('plugin', {
2647
keyPrefix: 'quick_links.frontend',
@@ -33,7 +54,7 @@ const Component = ({ navigate, request, hasDivider }) => {
3354
const tags = data?.tags || [];
3455
const links = data?.links_text?.split('\n') || [];
3556

36-
const handleNavigate = (e) => {
57+
const handleNavigate = (e: React.MouseEvent<HTMLAnchorElement>) => {
3758
e.preventDefault();
3859
e.stopPropagation();
3960
const url = e.currentTarget.getAttribute('href');
@@ -56,7 +77,7 @@ const Component = ({ navigate, request, hasDivider }) => {
5677
<div>
5778
{hasDivider && <div className="border-top mt-3" />}
5879
<div className="py-2 px-3 mt-3 small fw-bold quick-link">{t('quick_links')}</div>
59-
{tags?.map((tag) => {
80+
{tags?.map((tag: Tag) => {
6081
const href = `/tags/${encodeURIComponent(tag.slug_name)}`
6182
return (
6283
<a
@@ -69,7 +90,7 @@ const Component = ({ navigate, request, hasDivider }) => {
6990
)
7091
})}
7192

72-
{links?.map((link) => {
93+
{links?.map((link: string) => {
7394
const name = link.split(',')[0]
7495
const url = link.split(',')[1]?.trim()
7596
if (!url || !name) {

0 commit comments

Comments
 (0)