2023-01-07 14:30:20 +00:00
|
|
|
import { component$, Slot, useContextProvider } from '@builder.io/qwik'
|
2023-01-11 14:32:06 +00:00
|
|
|
import type { Env } from 'wildebeest/backend/src/types/env'
|
2023-02-06 21:49:00 +00:00
|
|
|
import { DocumentHead, Link, loader$ } from '@builder.io/qwik-city'
|
2023-01-06 10:38:28 +00:00
|
|
|
import * as instance from 'wildebeest/functions/api/v1/instance'
|
|
|
|
import type { InstanceConfig } from 'wildebeest/backend/src/types/configs'
|
2023-01-10 13:43:06 +00:00
|
|
|
import LeftColumn from '~/components/layout/LeftColumn/LeftColumn'
|
|
|
|
import RightColumn from '~/components/layout/RightColumn/RightColumn'
|
2023-01-07 14:30:20 +00:00
|
|
|
import { WildebeestLogo } from '~/components/MastodonLogo'
|
2023-01-10 12:43:35 +00:00
|
|
|
import { getCommitHash } from '~/utils/getCommitHash'
|
2023-01-10 13:47:25 +00:00
|
|
|
import { InstanceConfigContext } from '~/utils/instanceConfig'
|
2023-02-10 11:52:21 +00:00
|
|
|
import { getDocumentHead } from '~/utils/getDocumentHead'
|
2023-02-23 12:18:37 +00:00
|
|
|
import { getErrorHtml } from '~/utils/getErrorHtml/getErrorHtml'
|
2022-12-05 20:14:56 +00:00
|
|
|
|
2023-02-24 15:53:10 +00:00
|
|
|
export const instanceLoader = loader$<Promise<InstanceConfig>>(async ({ platform, html }) => {
|
2023-01-11 14:32:06 +00:00
|
|
|
const env = {
|
|
|
|
INSTANCE_DESCR: platform.INSTANCE_DESCR,
|
|
|
|
INSTANCE_TITLE: platform.INSTANCE_TITLE,
|
|
|
|
ADMIN_EMAIL: platform.ADMIN_EMAIL,
|
|
|
|
} as Env
|
2023-02-03 22:26:30 +00:00
|
|
|
try {
|
|
|
|
const response = await instance.handleRequest('', env)
|
|
|
|
const results = await response.text()
|
|
|
|
const json = JSON.parse(results) as InstanceConfig
|
|
|
|
return json
|
2023-02-23 12:18:37 +00:00
|
|
|
} catch (e: unknown) {
|
|
|
|
const error = e as { stack: string; cause: string }
|
|
|
|
console.warn(error.stack, error.cause)
|
|
|
|
throw html(500, getErrorHtml('An error occurred whilst retrieving the instance details'))
|
2023-02-03 22:26:30 +00:00
|
|
|
}
|
2023-01-11 14:32:06 +00:00
|
|
|
})
|
2023-01-06 10:38:28 +00:00
|
|
|
|
2022-12-05 20:14:56 +00:00
|
|
|
export default component$(() => {
|
2023-02-17 17:02:18 +00:00
|
|
|
useContextProvider(InstanceConfigContext, instanceLoader().value)
|
2023-01-12 13:11:15 +00:00
|
|
|
const commitHash = getCommitHash()
|
2023-01-06 10:38:28 +00:00
|
|
|
|
2022-12-05 20:14:56 +00:00
|
|
|
return (
|
2023-01-07 14:30:20 +00:00
|
|
|
<>
|
2023-01-10 13:47:25 +00:00
|
|
|
<header class="h-[3.9rem] z-50 sticky top-0 bg-wildebeest-600 p-3 w-full border-b border-wildebeest-700 xl:hidden">
|
2023-02-06 22:40:41 +00:00
|
|
|
<Link class="no-underline flex items-center w-max" aria-label="Wildebeest Home" href={'/'}>
|
2023-01-10 13:47:25 +00:00
|
|
|
<WildebeestLogo size="small" />
|
2023-02-06 21:49:00 +00:00
|
|
|
</Link>
|
2023-01-10 13:47:25 +00:00
|
|
|
</header>
|
2023-02-22 13:03:00 +00:00
|
|
|
<main class="flex-1 flex justify-center top-[3.9rem] max-w-screen">
|
2023-01-10 17:39:30 +00:00
|
|
|
<div class="w-fit md:w-72 hidden xl:block mx-2.5">
|
|
|
|
<div class="sticky top-2.5">
|
2023-01-10 13:47:25 +00:00
|
|
|
<LeftColumn />
|
2023-01-07 14:30:20 +00:00
|
|
|
</div>
|
2023-01-10 13:47:25 +00:00
|
|
|
</div>
|
2023-02-22 12:40:30 +00:00
|
|
|
<div class="w-0 xl:max-w-xl bg-wildebeest-600 xl:bg-transparent flex flex-col flex-1">
|
2023-02-06 22:40:41 +00:00
|
|
|
<div class="bg-wildebeest-600 rounded flex flex-1 flex-col">
|
2023-01-07 14:30:20 +00:00
|
|
|
<Slot />
|
2022-12-05 20:14:56 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-10 17:39:30 +00:00
|
|
|
<div class="w-fit md:w-72 border-l xl:border-l-0 border-wildebeest-700 xl:mx-2.5 flex flex-col">
|
|
|
|
<div class="xl:top-2.5 flex-1 flex flex-col">
|
2023-01-10 13:47:25 +00:00
|
|
|
<RightColumn />
|
2023-01-07 14:30:20 +00:00
|
|
|
</div>
|
2023-01-10 13:47:25 +00:00
|
|
|
</div>
|
2023-01-07 14:30:20 +00:00
|
|
|
</main>
|
2023-01-10 12:43:35 +00:00
|
|
|
<footer class="flex justify-end p-2 bg-wildebeest-600 border-t border-wildebeest-700 xl:bg-transparent xl:mt-10 xl:mx-6">
|
2023-01-12 13:11:15 +00:00
|
|
|
{commitHash && <p class="text-sm text-wildebeest-500">v.{commitHash}</p>}
|
2023-01-10 12:43:35 +00:00
|
|
|
</footer>
|
2023-01-07 14:30:20 +00:00
|
|
|
</>
|
2022-12-05 20:14:56 +00:00
|
|
|
)
|
|
|
|
})
|
2023-01-04 13:25:47 +00:00
|
|
|
|
2023-02-17 17:02:18 +00:00
|
|
|
export const head: DocumentHead = ({ resolveValue, head }) => {
|
|
|
|
const instance = resolveValue(instanceLoader)
|
2023-02-10 11:52:21 +00:00
|
|
|
|
|
|
|
return getDocumentHead(
|
|
|
|
{
|
|
|
|
description: instance.short_description ?? instance.description,
|
|
|
|
og: {
|
|
|
|
type: 'website',
|
|
|
|
url: instance.uri,
|
|
|
|
image: instance.thumbnail,
|
2023-01-06 10:38:28 +00:00
|
|
|
},
|
2023-02-10 11:52:21 +00:00
|
|
|
},
|
|
|
|
head
|
|
|
|
)
|
2023-01-04 13:25:47 +00:00
|
|
|
}
|