1
0
mirror of https://github.com/uetchy/namae.git synced 2025-07-02 06:20:02 +09:00

65 lines
1.6 KiB
TypeScript
Raw Normal View History

2020-08-20 00:57:33 +09:00
import React from 'react'
import { useTranslation } from 'react-i18next'
import { MdDomain } from 'react-icons/md'
2019-08-06 00:45:18 +09:00
2020-08-20 00:57:33 +09:00
import { Card, Repeater, DedicatedAvailability } from '../core'
import { zones } from '../../../util/zones'
2019-07-31 13:11:00 +09:00
2020-08-20 00:57:33 +09:00
const DomainCard: React.FC<{ query: string }> = ({ query }) => {
const { t } = useTranslation()
2020-06-11 22:00:16 +09:00
2020-08-20 00:57:33 +09:00
const sanitizedQuery = query.replace(/[^0-9a-zA-Z_-]/g, '').replace(/_/g, '-')
const lowerCase = sanitizedQuery.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) +
'.' +
2020-08-20 00:57:33 +09:00
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,
2020-08-20 00:57:33 +09:00
]
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`,
`${lowerCase}.run`,
2020-02-08 13:47:55 +09:00
`get${lowerCase}.com`,
2020-08-04 16:28:39 +02:00
`${lowerCase}.net`,
`${lowerCase}.eu`,
`${lowerCase}.info`,
`${lowerCase}.biz`,
`${lowerCase}.website`,
2020-08-20 00:57:33 +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>
2020-08-20 00:57:33 +09:00
)
}
2019-09-01 01:28:24 +09:00
2020-08-20 00:57:33 +09:00
export default DomainCard