mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-24 21:39:36 +02:00
Added url parser to support wider range of addresses
This commit is contained in:
parent
5968663be4
commit
a5504e6e80
7 changed files with 63 additions and 24 deletions
|
@ -2,7 +2,7 @@ import { Bookmark, Category } from '../../../interfaces';
|
|||
import classes from './BookmarkCard.module.css';
|
||||
|
||||
import Icon from '../../UI/Icons/Icon/Icon';
|
||||
import { iconParser } from '../../../utility/iconParser';
|
||||
import { iconParser, urlParser } from '../../../utility';
|
||||
|
||||
interface ComponentProps {
|
||||
category: Category;
|
||||
|
@ -13,19 +13,23 @@ const BookmarkCard = (props: ComponentProps): JSX.Element => {
|
|||
<div className={classes.BookmarkCard}>
|
||||
<h3>{props.category.name}</h3>
|
||||
<div className={classes.Bookmarks}>
|
||||
{props.category.bookmarks.map((bookmark: Bookmark) => (
|
||||
<a
|
||||
href={`http://${bookmark.url}`}
|
||||
target='_blank'
|
||||
key={`bookmark-${bookmark.id}`}>
|
||||
{bookmark.icon && (
|
||||
<div className={classes.BookmarkIcon}>
|
||||
<Icon icon={iconParser(bookmark.icon)} />
|
||||
</div>
|
||||
)}
|
||||
{bookmark.name}
|
||||
</a>
|
||||
))}
|
||||
{props.category.bookmarks.map((bookmark: Bookmark) => {
|
||||
const [displayUrl, redirectUrl] = urlParser(bookmark.url);
|
||||
|
||||
return (
|
||||
<a
|
||||
href={redirectUrl}
|
||||
target='_blank'
|
||||
key={`bookmark-${bookmark.id}`}>
|
||||
{bookmark.icon && (
|
||||
<div className={classes.BookmarkIcon}>
|
||||
<Icon icon={iconParser(bookmark.icon)} />
|
||||
</div>
|
||||
)}
|
||||
{bookmark.name}
|
||||
</a>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue