import { MarketingDrawer } from '@app/components/general'
import { metaSetter } from '@app/utils'
import type { PageProps } from '@app/types'
import { companyName, OSSRoutes } from '@app/configs'
import { GetStaticProps } from 'next'
import { URL } from 'url'
import { GrStar } from 'react-icons/gr'
import { SectionContainer } from '@app/components/stateless/containers/section-container'
import { Header, Header3 } from '@app/components/general/header'
function OSSCell({ item }: { item: (typeof OSSRoutes)[number] }) {
return (
{item.name}
{item.description}
{item.fullName.toLowerCase()}
{item.stars ?? 0}
)
}
function OpenSource({
name,
items,
}: PageProps & {
items: typeof OSSRoutes
}) {
return (
Ethos
Open source has a big role on the way we build our products here.
We give back to the community and provide some free and simple
software.
{items?.map((item) => (
-
))}
)
}
export default metaSetter(
{ OpenSource },
{
title: `${companyName}: Open Source projects we support`,
description: `A list of Open-Source projects we contribute to. Some of the projects help make our system unique.`,
}
)
const getItems = async (): Promise => {
const items: typeof OSSRoutes = []
for await (const oss of OSSRoutes) {
let path
try {
path = new URL(oss.href)?.pathname
} catch (e) {
console.error(e)
}
let props
let res
try {
res = await fetch(`http://api.github.com/repos${path}`, {
headers: {
Authorization: process.env.GITHUB_TOKEN || '',
},
})
} catch (e) {
console.error(e)
}
if (res && res?.ok) {
try {
props = await res?.json()
} catch (e) {
console.error(e)
}
}
if (props) {
items.push({
name: props?.name,
description: props?.description,
href: props?.html_url,
stars: props?.stargazers_count,
fullName: props?.full_name,
})
}
}
return items
}
export const getStaticProps: GetStaticProps = async () => {
const items = await getItems()
return {
props: {
items: items?.length ? items : OSSRoutes,
},
revalidate: 3600 * 12, // every 12 hours
}
}