resolve issues with new features
This commit is contained in:
@@ -185,7 +185,7 @@ const BookStackSearchWidget: React.FC = () => {
|
||||
)}
|
||||
|
||||
{results.length > 0 && (
|
||||
<Box sx={{ mt: 1 }}>
|
||||
<Box sx={{ mt: 1, maxHeight: 300, overflow: 'auto' }}>
|
||||
{results.map((result, index) => (
|
||||
<ResultRow
|
||||
key={result.id}
|
||||
|
||||
@@ -8,55 +8,43 @@ import {
|
||||
Divider,
|
||||
} from '@mui/material';
|
||||
import { Link as LinkIcon, OpenInNew } from '@mui/icons-material';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { configApi } from '../../services/config';
|
||||
import type { LinkCollection } from '../../types/config.types';
|
||||
|
||||
function LinksWidget() {
|
||||
const { data: externalLinks } = useQuery({
|
||||
queryKey: ['external-links'],
|
||||
queryFn: () => configApi.getExternalLinks(),
|
||||
staleTime: 10 * 60 * 1000,
|
||||
});
|
||||
|
||||
const collections = externalLinks?.linkCollections ?? [];
|
||||
const nonEmpty = collections.filter((c) => c.links.length > 0);
|
||||
|
||||
if (nonEmpty.length === 0) return null;
|
||||
interface LinksWidgetProps {
|
||||
collection: LinkCollection;
|
||||
}
|
||||
|
||||
function LinksWidget({ collection }: LinksWidgetProps) {
|
||||
return (
|
||||
<>
|
||||
{nonEmpty.map((collection) => (
|
||||
<Card key={collection.id}>
|
||||
<CardContent>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', mb: 1 }}>
|
||||
<LinkIcon color="primary" sx={{ mr: 1 }} />
|
||||
<Typography variant="h6">{collection.name}</Typography>
|
||||
</Box>
|
||||
<Divider sx={{ mb: 1.5 }} />
|
||||
<Stack spacing={0.5}>
|
||||
{collection.links.map((link, i) => (
|
||||
<Link
|
||||
key={i}
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
underline="hover"
|
||||
sx={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 0.5,
|
||||
py: 0.5,
|
||||
}}
|
||||
>
|
||||
{link.name}
|
||||
<OpenInNew sx={{ fontSize: 14, opacity: 0.6 }} />
|
||||
</Link>
|
||||
))}
|
||||
</Stack>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</>
|
||||
<Card>
|
||||
<CardContent>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', mb: 1 }}>
|
||||
<LinkIcon color="primary" sx={{ mr: 1 }} />
|
||||
<Typography variant="h6">{collection.name}</Typography>
|
||||
</Box>
|
||||
<Divider sx={{ mb: 1.5 }} />
|
||||
<Stack spacing={0.5}>
|
||||
{collection.links.map((link, i) => (
|
||||
<Link
|
||||
key={i}
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
underline="hover"
|
||||
sx={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 0.5,
|
||||
py: 0.5,
|
||||
}}
|
||||
>
|
||||
{link.name}
|
||||
<OpenInNew sx={{ fontSize: 14, opacity: 0.6 }} />
|
||||
</Link>
|
||||
))}
|
||||
</Stack>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user