mirror of
https://github.com/uetchy/namae.git
synced 2025-10-14 23:22:19 +09:00
feat: support for Firefox Add-ons
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
FaSlack,
|
||||
FaTwitter,
|
||||
FaCloudflare,
|
||||
FaFirefoxBrowser,
|
||||
} from 'react-icons/fa';
|
||||
import { IoIosBeer, IoMdAppstore } from 'react-icons/io';
|
||||
import { MdDomain } from 'react-icons/md';
|
||||
@@ -60,6 +61,7 @@ const supportedProviders: Record<string, React.ReactNode> = {
|
||||
githubSearch: <FaGithubAlt />,
|
||||
appStore: <SiAppstore />,
|
||||
playStore: <IoMdAppstore />,
|
||||
firefoxAddons: <FaFirefoxBrowser />,
|
||||
chromeWebStore: <RiChromeFill />,
|
||||
nta: <RiBuilding2Fill />,
|
||||
};
|
||||
|
@@ -8,6 +8,7 @@ import CloudflareCard from './providers/Cloudflare';
|
||||
import CratesioCard from './providers/Cratesio';
|
||||
import DomainCard from './providers/Domains';
|
||||
import FirebaseCard from './providers/Firebase';
|
||||
import FirefoxAddonsCard from './providers/FirefoxAddons';
|
||||
import GithubCard from './providers/GitHubOrganization';
|
||||
import GithubSearchCard from './providers/GitHubSearch';
|
||||
import GitLabCard from './providers/GitLab';
|
||||
@@ -65,6 +66,7 @@ const Index: React.FC<{ query: string }> = ({ query }) => {
|
||||
<GithubSearchCard query={query} />
|
||||
<AppStoreCard query={query} />
|
||||
<PlayStoreCard query={query} />
|
||||
<FirefoxAddonsCard query={query} />
|
||||
<ChromeWebStoreCard query={query} />
|
||||
{language === 'ja' ? <NtaCard query={query} /> : null}
|
||||
</Cards>
|
||||
|
56
src/components/cards/providers/FirefoxAddons.tsx
Normal file
56
src/components/cards/providers/FirefoxAddons.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
import useFetch from 'fetch-suspense';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { FaFirefoxBrowser } from 'react-icons/fa';
|
||||
import { RiChromeFill } from 'react-icons/ri';
|
||||
import { Card, Result } from '../core';
|
||||
|
||||
const Search: React.FC<{ query: string }> = ({ query }) => {
|
||||
const { t } = useTranslation();
|
||||
const response = useFetch(
|
||||
`/api/services/firefox-addons/${encodeURIComponent(query)}`
|
||||
) as {
|
||||
result: Array<{
|
||||
name: string;
|
||||
url: string;
|
||||
author: string;
|
||||
description: string;
|
||||
id: string;
|
||||
}>;
|
||||
};
|
||||
const apps = response.result;
|
||||
|
||||
return (
|
||||
<>
|
||||
{apps && apps.length > 0 ? (
|
||||
apps.map((app) => (
|
||||
<Result
|
||||
title={app.name.split(/\s[-–—\-:]\s/)[0]}
|
||||
message={`${app.author}: ${app.description}`}
|
||||
link={app.url}
|
||||
icon={<FaFirefoxBrowser />}
|
||||
key={app.id}
|
||||
/>
|
||||
))
|
||||
) : (
|
||||
<Result
|
||||
title={t('noResult')}
|
||||
message={t('noResult')}
|
||||
icon={<FaFirefoxBrowser />}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const FirefoxAddonsCard: React.FC<{ query: string }> = ({ query }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Card title={t('providers.firefoxAddons')}>
|
||||
<Search query={query} />
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default FirefoxAddonsCard;
|
@@ -25,7 +25,7 @@ const Search: React.FC<{ query: string }> = ({ query }) => {
|
||||
{apps && apps.length > 0 ? (
|
||||
apps.map((app) => (
|
||||
<Result
|
||||
title={app.name}
|
||||
title={app.name.split(/\s[-–—\-:]\s/)[0]}
|
||||
message={`${app.author}: ${app.description}`}
|
||||
link={app.url}
|
||||
icon={<IoMdAppstore />}
|
||||
|
Reference in New Issue
Block a user