---
import { getResourceTypes } from "../libs/resources";
import Resources from "./Resources.astro";
import { capitalCase } from "change-case";

interface Props {
  resourcesUrl?: string | undefined;
  githubOrg?: string | undefined;
}

const { resourcesUrl, githubOrg } = Astro.props;

const resourceTypes = await getResourceTypes(resourcesUrl);
---

{
  resourceTypes.map((resourceType) => (
    <>
      <h2 id={resourceType}>{capitalCase(resourceType)}</h2>
      <Resources
        type={resourceType}
        resourcesUrl={resourcesUrl}
        githubOrg={githubOrg}
      />
    </>
  ))
}
