Skip to content

Full Toolkit for Next-Level Domain Analysis

1.3 KB
Raw Blame
import type { Metadata } from 'next';
import type { FC } from 'react';

import { lookupRelatedCerts } from '@/lib/certs';
import { recordLookupAfter } from '@/lib/search';

import { CertsTable } from './_components/table';

type CertsResultsPageProps = {
  params: Promise<{
    domain: string;
  }>;
};

export const generateMetadata = async ({
  params,
}: CertsResultsPageProps): Promise<Metadata> => {
  const { domain } = await params;

  return {
    title: `Certificate Logs for ${domain}`,
    openGraph: {
      title: `Certificate Logs for ${domain}`,
      url: `/lookup/${domain}/certs`,
    },
    alternates: {
      canonical: `/lookup/${domain}/certs`,
    },
  };
};

const CertsResultsPage: FC<CertsResultsPageProps> = async (props) => {
  const params = await props.params;

  const { domain } = params;

  const certs = await lookupRelatedCerts(domain);

  await recordLookupAfter(domain, 'certs', certs.length > 0);

  if (!certs.length) {
    return (
      <p className="mt-8 text-center text-zinc-500 dark:text-zinc-400">
        No issued certificates found!
      </p>
    );
  }

  return (
    <>
      <CertsTable certs={certs} />

      <p className="mt-8 text-center text-zinc-500 dark:text-zinc-400">
        Found {certs.length} certificates.
      </p>
    </>
  );
};

export default CertsResultsPage;