mirror of
https://github.com/uetchy/namae.git
synced 2025-10-15 07:32:19 +09:00
feat: subreddit card
This commit is contained in:
@@ -24,6 +24,7 @@ import RubyGemsCard from './providers/RubyGems';
|
||||
import S3Card from './providers/S3';
|
||||
import SlackCard from './providers/Slack';
|
||||
import SpectrumCard from './providers/Spectrum';
|
||||
import SubredditCard from './providers/Subreddit';
|
||||
import TwitterCard from './providers/Twitter';
|
||||
import VercelCard from './providers/Vercel';
|
||||
|
||||
@@ -53,6 +54,7 @@ const Index: React.FC<{ query: string }> = ({ query }) => {
|
||||
<SlackCard query={query} />
|
||||
{/* <InstagramCard query={query} /> */}
|
||||
<SpectrumCard query={query} />
|
||||
<SubredditCard query={query} />
|
||||
<S3Card query={query} />
|
||||
<FirebaseCard query={query} />
|
||||
</Cards>
|
||||
|
32
src/components/cards/providers/Subreddit.tsx
Normal file
32
src/components/cards/providers/Subreddit.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { FaReddit } from 'react-icons/fa';
|
||||
|
||||
import { Card, Repeater, DedicatedAvailability } from '../core';
|
||||
|
||||
const SubredditCard: React.FC<{ query: string }> = ({ name }) => {
|
||||
const { t } = useTranslation();
|
||||
const lowerCase = name.toLowerCase();
|
||||
|
||||
const names = [name];
|
||||
const moreNames = [
|
||||
`get${lowerCase}`,
|
||||
`${lowerCase}-team`,
|
||||
];
|
||||
|
||||
return (
|
||||
<Card title={t('providers.reddit')}>
|
||||
<Repeater items={names} moreItems={moreNames}>
|
||||
{(name) => (
|
||||
<DedicatedAvailability
|
||||
name={name}
|
||||
service="reddit" // route to http://namae.dev/api/services/reddit/<query> which is /api/services/reddit/[query].ts on GitHub
|
||||
link={`https://reddit.com/r/${name}`}
|
||||
prefix="reddit.com/r/"
|
||||
icon={<FaReddit />}
|
||||
/>
|
||||
)}
|
||||
</Repeater>
|
||||
</Card>
|
||||
);
|
||||
};
|
Reference in New Issue
Block a user