Landing page GitHub releases pulling (#1633)

* new route for latest version

* client side fetching from own API

* Server side fetching

* implement changes

* remove LatestVersion

* typescript

---------

Co-authored-by: Brendan Allan <brendonovich@outlook.com>
This commit is contained in:
Alex 2023-10-20 07:32:30 +02:00 committed by GitHub
parent a709f2b642
commit 5e272f796b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 8 deletions

View file

@ -9,8 +9,6 @@ import { Tooltip } from '@sd/ui';
import HomeCTA from './HomeCTA';
const RELEASE_VERSION = 'Alpha v0.1.1';
interface Platform {
name: string;
os?: string;
@ -50,7 +48,11 @@ const platforms = {
const BASE_DL_LINK = '/api/releases/desktop/stable';
export function Downloads() {
interface Props {
latestVersion: string;
}
export function Downloads({ latestVersion }: Props) {
const [selectedPlatform, setSelectedPlatform] = useState<Platform | null>(null);
const currentPlatform = useCurrentPlatform();
@ -113,7 +115,7 @@ export function Downloads() {
</div>
)}
<p className="animation-delay-3 z-30 mt-3 px-6 text-center text-sm text-gray-400 fade-in">
{RELEASE_VERSION}
{latestVersion}
{formattedVersion && (
<>
<span className="mx-2 opacity-50">|</span>
@ -174,10 +176,10 @@ function useCurrentPlatform() {
return currentPlatform;
}
interface Props {
interface PlatformProps {
platform: Platform;
}
function Platform({ platform, ...props }: ComponentProps<'a'> & Props) {
function Platform({ platform, ...props }: ComponentProps<'a'> & PlatformProps) {
const { links } = platform;
const Outer = links

View file

@ -31,4 +31,5 @@ webhook.on('release', ({ payload }) => {
revalidatePath('/docs', 'layout');
revalidatePath(`/docs/alpha/${payload.release.tag_name}`, 'page');
revalidatePath(`/`, 'page');
});

View file

@ -1,6 +1,8 @@
import Image from 'next/image';
import CyclingImage from '~/components/CyclingImage';
import { toTitleCase } from '~/utils/util';
import { getLatestRelease, getReleaseFrontmatter, githubFetch } from './api/github';
import { Background } from './Background';
import { Downloads } from './Downloads';
import { NewBanner } from './NewBanner';
@ -20,7 +22,10 @@ export const metadata = {
}
};
export default function Page() {
export default async function Page() {
const release = await githubFetch(getLatestRelease);
const { frontmatter } = getReleaseFrontmatter(release);
return (
<>
<Background />
@ -52,7 +57,11 @@ export default function Page() {
Designed for creators, hoarders and the painfully disorganized.
</span>
</p>
<Downloads />
<Downloads
latestVersion={[toTitleCase(frontmatter.category), `v${release.tag_name}`]
.filter(Boolean)
.join(' ')}
/>
<div className="pb-6 xs:pb-24">
<div
className="xl2:relative z-30 flex h-[255px] w-full px-6