From 2d13cde96e7ecdd4888395bbae52eabe98f3db3d Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 18 Jan 2025 09:07:31 -0800 Subject: [PATCH] Adds og:image for showing the page preview --- components/party/PartyHead/index.tsx | 4 ++++ utils/api.tsx | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/components/party/PartyHead/index.tsx b/components/party/PartyHead/index.tsx index 34590904..22c3dc15 100644 --- a/components/party/PartyHead/index.tsx +++ b/components/party/PartyHead/index.tsx @@ -2,6 +2,7 @@ import React from 'react' import Head from 'next/head' import { useRouter } from 'next/router' import { useTranslation } from 'next-i18next' +import api from '~utils/api' import generateTitle from '~utils/generateTitle' @@ -18,6 +19,7 @@ const PartyHead = ({ party, meta }: Props) => { const router = useRouter() const locale = router.locale && ['en', 'ja'].includes(router.locale) ? router.locale : 'en' + const previewUrl = api.previewUrl(party.shortcode) return ( @@ -52,6 +54,7 @@ const PartyHead = ({ party, meta }: Props) => { content={`https://app.granblue.team/p/${party.shortcode}`} /> + {/* Twitter */} @@ -67,6 +70,7 @@ const PartyHead = ({ party, meta }: Props) => { raidName: party.raid ? party.raid.name[locale] : '', })} /> + ) } diff --git a/utils/api.tsx b/utils/api.tsx index fc9c29ed..892212b5 100644 --- a/utils/api.tsx +++ b/utils/api.tsx @@ -139,6 +139,10 @@ class Api { return axios.get(resourceUrl, params) } + previewUrl(shortcode: string): string { + return `${this.url}/parties/${shortcode}/preview` + } + raidGroups(params?: {}) { const resourceUrl = `${this.url}/raids/groups` return axios.get(resourceUrl, params)