Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

⚡️ Render the poll description on the server on the invite page (#3466)

Luke Vellafeb2cb60799e
diff --git a/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/admin-page.tsx b/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/admin-page.tsx
index aa73ae603..fab4029c3 100644
--- a/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/admin-page.tsx
+++ b/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/admin-page.tsx
@@ -3,6 +3,7 @@ import { useInstancePolicy } from "@/features/instance-policy/client";
import { usePoll } from "@/features/poll/client";
import { CommentsSheet } from "@/features/poll/components/comments-sheet";
import { EventCard } from "@/features/poll/components/event-card";
+import { EventMetaDescription } from "@/features/poll/components/event-meta-description";
import { PollFooter } from "@/features/poll/components/poll-footer";
import { ResponsiveResults } from "@/features/poll/components/responsive-results";
import { VotingForm } from "@/features/poll/components/voting-form";
@@ -27,7 +28,11 @@ export function AdminPage({
return (
<div className="space-y-3 lg:space-y-4">
<GuestPollAlert />
- <EventCard />
+ <EventCard
+ description={
+ <EventMetaDescription className="mt-4" content={poll.description} />
+ }
+ />
<VotingForm>
<ResponsiveResults />
</VotingForm>
diff --git a/apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx b/apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx
index 8049df9d1..85ddc6a70 100644
--- a/apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx
+++ b/apps/web/src/app/[locale]/invite/[urlId]/invite-page.tsx
@@ -19,8 +19,10 @@ import { useHydrated } from "@/lib/datetime/use-hydrated";
* nothing else is fetched.
*/
export function InvitePage({
+ description,
footerLinks,
}: {
+ description: React.ReactNode;
footerLinks: { label: string; href: string }[];
}) {
const hydrated = useHydrated();
@@ -37,7 +39,7 @@ export function InvitePage({
className="mx-auto w-full max-w-4xl space-y-3"
>
<CreatorBanner />
- <EventCard />
+ <EventCard description={description} />
<VotingForm>
<ResponsiveResults />
<FloatingComments />
diff --git a/apps/web/src/app/[locale]/invite/[urlId]/page.tsx b/apps/web/src/app/[locale]/invite/[urlId]/page.tsx
index 485df399f..48f685dd6 100644
--- a/apps/web/src/app/[locale]/invite/[urlId]/page.tsx
+++ b/apps/web/src/app/[locale]/invite/[urlId]/page.tsx
@@ -5,6 +5,7 @@ import { Suspense } from "react";
import { SessionRefresher } from "@/components/session-refresher";
import { loadFooterLinks } from "@/features/instance-settings/loaders";
import { PollProvider } from "@/features/poll/client";
+import { EventMetaDescription } from "@/features/poll/components/event-meta-description";
import { PollBrandingFromContext } from "@/features/poll/components/poll-branding";
import { LegacyPollContextProvider } from "@/features/poll/components/poll-context-provider";
import { VisibilityProvider } from "@/features/poll/components/visibility";
@@ -84,7 +85,16 @@ async function InvitePageContent({ params, searchParams }: PageProps) {
<LegacyPollContextProvider>
<VisibilityProvider>
<PollBrandingFromContext />
- <InvitePage footerLinks={footerLinks} />
+ <InvitePage
+ // Rendered here so the markdown parser stays on the server
+ description={
+ <EventMetaDescription
+ className="mt-4"
+ content={poll.description}
+ />
+ }
+ footerLinks={footerLinks}
+ />
</VisibilityProvider>
</LegacyPollContextProvider>
</PollProvider>
diff --git a/apps/web/src/features/poll/components/event-card.tsx b/apps/web/src/features/poll/components/event-card.tsx
index d80a3fd5a..352a11f42 100644
--- a/apps/web/src/features/poll/components/event-card.tsx
+++ b/apps/web/src/features/poll/components/event-card.tsx
@@ -8,7 +8,6 @@ import { PollConferencingSummary } from "@/features/conferencing/components/poll
import { useInstancePolicy } from "@/features/instance-policy/client";
import { usePoll } from "@/features/poll/client";
import {
- EventMetaDescription,
EventMetaItem,
EventMetaList,
EventMetaTitle,
@@ -53,7 +52,11 @@ function IconDescription({
* location. `EventCard` frames it as a standalone card with the response
* legend; the vote page places it in the sidebar of the merged card.
*/
-export function EventDetails() {
+export function EventDetails({
+ description,
+}: {
+ description: React.ReactNode;
+}) {
const poll = usePoll();
const branding = useBranding();
const { spaceBrandingAllowed } = useInstancePolicy();
@@ -81,7 +84,7 @@ export function EventDetails() {
</div>
) : null}
<EventMetaTitle>{poll.title}</EventMetaTitle>
- <EventMetaDescription className="mt-4" content={poll.description} />
+ {description}
<EventMetaList className="mt-4">
{poll.user ? (
<EventMetaItem>
@@ -112,13 +115,13 @@ export function EventDetails() {
);
}
-export function EventCard() {
+export function EventCard({ description }: { description: React.ReactNode }) {
const poll = usePoll();
return (
<Card>
<RandomGradientBar />
<CardContent>
- <EventDetails />
+ <EventDetails description={description} />
<h2 className="mt-4 mb-1.5 text-muted-foreground text-xs">
<Trans i18nKey="responseOptions" defaults="Response options" />
</h2>
diff --git a/apps/web/src/features/poll/components/event-meta-description.tsx b/apps/web/src/features/poll/components/event-meta-description.tsx
new file mode 100644
index 000000000..688003514
--- /dev/null
+++ b/apps/web/src/features/poll/components/event-meta-description.tsx
@@ -0,0 +1,23 @@
+import { cn } from "@rallly/ui";
+import { MarkdownDescription } from "@rallly/ui/markdown-description";
+
+// Kept apart from event-meta so client components that only need the title
+// and meta list don't pull the markdown parser into their bundle. Render it
+// on the server wherever the poll is available there, as the invite page does.
+export function EventMetaDescription({
+ className,
+ content,
+}: {
+ className?: string;
+ content?: string | null;
+}) {
+ if (!content) {
+ return null;
+ }
+ return (
+ <MarkdownDescription
+ content={content}
+ className={cn(className, "min-w-0 opacity-90")}
+ />
+ );
+}
diff --git a/apps/web/src/features/poll/components/event-meta.tsx b/apps/web/src/features/poll/components/event-meta.tsx
index 985e09d1d..a91e1d321 100644
--- a/apps/web/src/features/poll/components/event-meta.tsx
+++ b/apps/web/src/features/poll/components/event-meta.tsx
@@ -1,5 +1,4 @@
import { cn } from "@rallly/ui";
-import { MarkdownDescription } from "@rallly/ui/markdown-description";
import { OptimizedAvatarImage } from "@/components/optimized-avatar-image";
export function EventMetaTitle({
@@ -16,24 +15,6 @@ export function EventMetaTitle({
);
}
-export function EventMetaDescription({
- className,
- content,
-}: {
- className?: string;
- content?: string | null;
-}) {
- if (!content) {
- return null;
- }
- return (
- <MarkdownDescription
- content={content}
- className={cn(className, "min-w-0 opacity-90")}
- />
- );
-}
-
export function EventMetaList({
className,
children,
diff --git a/apps/web/src/features/poll/invite/components/event-sidebar.tsx b/apps/web/src/features/poll/invite/components/event-sidebar.tsx
index a4a0ed4f1..9624f6907 100644
--- a/apps/web/src/features/poll/invite/components/event-sidebar.tsx
+++ b/apps/web/src/features/poll/invite/components/event-sidebar.tsx
@@ -3,11 +3,11 @@ import { Trans } from "react-i18next/TransWithoutContext";
import { PollConferencingSummary } from "@/features/conferencing/components/poll-conferencing-summary";
import type { PollConferencing } from "@/features/conferencing/schema";
import {
- EventMetaDescription,
EventMetaItem,
EventMetaList,
EventMetaTitle,
} from "@/features/poll/components/event-meta";
+import { EventMetaDescription } from "@/features/poll/components/event-meta-description";
import TruncatedLinkify from "@/features/poll/components/truncated-linkify";
import { PoweredByLink } from "@/features/poll/vote/components/powered-by-link";
import { SpaceIcon } from "@/features/space/components/space-icon";