Full Toolkit for Next-Level Domain Analysis
Improve related domains links 👌
Felix Wotschofskyceb581fa32ae
diff --git a/components/InvertedWWWLink.tsx b/components/InvertedWWWLink.tsxdeleted file mode 100644index e35ca4e..0000000--- a/components/InvertedWWWLink.tsx+++ /dev/null@@ -1,19 +0,0 @@-import NextLink from 'next/link';-import { Link } from '@chakra-ui/react';--type InvertedWWWLinkProps = {- domain: string;-};--const InvertedWWWLink = ({ domain: original }: InvertedWWWLinkProps) => {- const isWWW = original.startsWith('www.');- const inverted = isWWW ? original.substring(4) : `www.${original}`;-- return (- <NextLink href={`/lookup/${inverted}`} passHref>- <Link>Look up {inverted}</Link>- </NextLink>- );-};--export default InvertedWWWLink;diff --git a/components/RelatedDomains.tsx b/components/RelatedDomains.tsxnew file mode 100644index 0000000..f427678--- /dev/null+++ b/components/RelatedDomains.tsx@@ -0,0 +1,34 @@+import NextLink from 'next/link';+import { Button, Stack } from '@chakra-ui/react';++type RelatedDomainsProps = {+ domain: string;+};++const RelatedDomains = ({ domain: original }: RelatedDomainsProps) => {+ const domains = [];++ const splitOriginal = original.split('.');+ for (let i = 1; i < splitOriginal.length - 1; i++) {+ const domain = splitOriginal.slice(i).join('.');+ domains.push(domain);+ }++ if (!original.startsWith('www.')) {+ domains.unshift(`www.${original}`);+ }++ return (+ <Stack spacing={4} direction="row" align="center">+ {domains.map((domain) => (+ <NextLink key={domain} href={`/lookup/${domain}`}>+ <a>+ <Button size="xs">{domain}</Button>+ </a>+ </NextLink>+ ))}+ </Stack>+ );+};++export default RelatedDomains;diff --git a/pages/lookup/[domain].tsx b/pages/lookup/[domain].tsxindex bf2d06f..fd4057a 100644--- a/pages/lookup/[domain].tsx+++ b/pages/lookup/[domain].tsx@@ -16,7 +16,7 @@ import { ExternalLinkIcon } from '@chakra-ui/icons';import CertInfo from '@/components/CertInfo';import DnsLookup, { ResolvedRecords } from '@/utils/DnsLookup';import DnsTable from '@/components/DnsTable';-import InvertedWWWLink from '@/components/InvertedWWWLink';+import RelatedDomains from '@/components/RelatedDomains';import SearchForm from '@/components/SearchForm';import WhoisInfo from '@/components/WhoisInfo';@@ -83,7 +83,7 @@ const LookupDomain = ({</Link></Heading>- <InvertedWWWLink domain={router.query.domain as string} />+ <RelatedDomains domain={router.query.domain as string} /><Tabs isLazy mt={6}><TabList>