1
0
mirror of https://github.com/uetchy/namae.git synced 2025-07-01 22:10:04 +09:00

57 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-09-17 14:30:26 +09:00
import React from 'react';
import {useTranslation} from 'react-i18next';
2020-02-06 13:16:30 +09:00
import {MdDomain} from 'react-icons/md';
2019-08-06 00:45:18 +09:00
2020-02-05 16:22:35 +09:00
import {Card, Repeater, DedicatedAvailability} from '../core';
2020-02-08 18:10:45 +09:00
import {zones} from '../../../util/zones';
2019-07-31 13:11:00 +09:00
2019-09-17 14:30:26 +09:00
const DomainCard: React.FC<{query: string}> = ({query}) => {
const {t} = useTranslation();
const lowerCase = query.toLowerCase();
2019-07-31 13:11:00 +09:00
2020-02-08 18:10:45 +09:00
const domainHackSuggestions = zones
2020-02-09 09:07:28 +09:00
.map((zone) => new RegExp(`${zone}$`).exec(lowerCase.slice(1)))
2020-02-08 18:10:45 +09:00
.filter((s): s is RegExpExecArray => s !== null)
.map(
(m) =>
2020-02-09 09:07:28 +09:00
lowerCase.substring(0, m.index + 1) +
'.' +
lowerCase.substring(m.index + 1),
);
2020-02-08 18:10:45 +09:00
const names = [
`${lowerCase}.com`,
2020-04-21 16:56:55 +09:00
`${lowerCase}app.com`,
2020-02-08 18:10:45 +09:00
`${lowerCase}.app`,
2020-04-30 14:05:43 +09:00
`${lowerCase}.dev`,
`${lowerCase}.org`,
2020-04-21 16:56:55 +09:00
`${lowerCase}.io`,
2020-02-08 18:10:45 +09:00
...domainHackSuggestions,
];
2019-08-06 00:45:18 +09:00
const moreNames = [
2020-02-08 13:47:55 +09:00
`${lowerCase}.sh`,
2019-08-06 00:45:18 +09:00
`${lowerCase}.tools`,
2020-04-21 16:56:55 +09:00
`${lowerCase}.design`,
`${lowerCase}.build`,
2020-02-08 13:47:55 +09:00
`get${lowerCase}.com`,
2019-09-17 14:30:26 +09:00
];
2019-08-06 00:45:18 +09:00
2019-07-31 13:11:00 +09:00
return (
2019-08-06 00:45:18 +09:00
<Card title={t('providers.domains')}>
<Repeater items={names} moreItems={moreNames}>
{(name) => (
<DedicatedAvailability
name={name}
2019-08-07 22:25:51 +09:00
message="Go to Domainr.com"
2019-08-06 00:45:18 +09:00
service="domain"
link={`https://domainr.com/?q=${name}`}
2020-02-06 13:16:30 +09:00
icon={<MdDomain />}
2019-08-06 00:45:18 +09:00
/>
)}
</Repeater>
2019-07-31 13:11:00 +09:00
</Card>
2019-09-17 14:30:26 +09:00
);
};
2019-09-01 01:28:24 +09:00
2019-09-17 14:30:26 +09:00
export default DomainCard;