Add rich HTML course lead/body and refresh AI course media from delivery v2.
Deploy edu.mstaut.ir / deploy (push) Has been cancelled

Course detail pages can show sanitized HTML ad copy under the hero and a structured body; posters and brochures are updated for both AI workshops.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
smhk1376andCursor committed 2026-10-20 00:54:30 +03:30
1 parent afd2b3333c
commit bd2cfa5a26
26 files changed
+801 -30

No files matched your search

+10 -4
View File
@@ -1,3 +1,4 @@
import type { ReactNode } from "react";
import Image from "next/image";
import { Container } from "@/components/atoms/Container";
import { Heading } from "@/components/atoms/Heading";
@@ -14,7 +15,8 @@ export function PageHero({
showField = true,
}: {
title: string;
intro?: string;
/** Plain string or rich content (e.g. sanitized HTML) under the title. */
intro?: ReactNode;
eyebrow?: string;
imageUrl?: string;
actions?: React.ReactNode;
@@ -71,9 +73,13 @@ export function PageHero({
{title}
</Heading>
{intro ? (
<p className="mt-5 max-w-2xl border-t border-secondary/50 pt-5 text-base leading-7 text-pretty text-primary-foreground/70 sm:text-lg sm:leading-8">
{intro}
</p>
<div className="mt-5 max-w-2xl border-t border-secondary/50 pt-5 text-pretty text-primary-foreground/70">
{typeof intro === "string" ? (
<p className="text-base leading-7 sm:text-lg sm:leading-8">{intro}</p>
) : (
intro
)}
</div>
) : null}
{actions ? (
<div className="mt-8 flex flex-wrap gap-3">{actions}</div>
@@ -0,0 +1,53 @@
import { cn } from "@/lib/utils";
import { sanitizeCourseHtml } from "@/lib/sanitize-html";
type RichHtmlTone = "default" | "onPrimary";
const toneClass: Record<RichHtmlTone, string> = {
default: cn(
"max-w-none text-base leading-7 text-foreground/90",
"[&_h2]:mt-8 [&_h2]:mb-3 [&_h2]:text-lg [&_h2]:font-bold [&_h2]:text-foreground",
"[&_h3]:mt-6 [&_h3]:mb-2 [&_h3]:text-base [&_h3]:font-bold [&_h3]:text-foreground",
"[&_h4]:mt-4 [&_h4]:mb-2 [&_h4]:text-sm [&_h4]:font-semibold",
"[&_p]:mb-3 [&_p:last-child]:mb-0",
"[&_ul]:my-3 [&_ul]:list-disc [&_ul]:ps-5 [&_ul]:space-y-1.5",
"[&_ol]:my-3 [&_ol]:list-decimal [&_ol]:ps-5 [&_ol]:space-y-1.5",
"[&_li]:leading-7",
"[&_a]:font-medium [&_a]:text-primary [&_a]:underline [&_a]:underline-offset-4",
"[&_strong]:font-semibold [&_strong]:text-foreground",
"[&_hr]:my-6 [&_hr]:border-border",
),
onPrimary: cn(
"max-w-none text-base leading-7 text-primary-foreground/75 sm:text-lg sm:leading-8",
"[&_h2]:mt-4 [&_h2]:mb-2 [&_h2]:text-lg [&_h2]:font-bold [&_h2]:text-primary-foreground",
"[&_h3]:mt-3 [&_h3]:mb-2 [&_h3]:text-base [&_h3]:font-bold [&_h3]:text-primary-foreground",
"[&_p]:mb-3 [&_p:last-child]:mb-0",
"[&_ul]:my-3 [&_ul]:list-disc [&_ul]:ps-5 [&_ul]:space-y-1.5",
"[&_ol]:my-3 [&_ol]:list-decimal [&_ol]:ps-5 [&_ol]:space-y-1.5",
"[&_li]:leading-7",
"[&_a]:font-medium [&_a]:text-secondary [&_a]:underline [&_a]:underline-offset-4",
"[&_strong]:font-semibold [&_strong]:text-primary-foreground",
"[&_br]:leading-8",
),
};
/** Renders sanitized HTML with typography styles. */
export function RichHtmlContent({
html,
tone = "default",
className,
}: {
html: string;
tone?: RichHtmlTone;
className?: string;
}) {
const clean = sanitizeCourseHtml(html);
if (!clean) return null;
return (
<div
className={cn(toneClass[tone], className)}
dangerouslySetInnerHTML={{ __html: clean }}
/>
);
}
@@ -37,6 +37,8 @@ type Payload = {
registrationUrl: string;
posterImageUrl: string;
brochureImageUrl: string;
leadHtml: string;
bodyHtml: string;
seoDescription: string;
published: boolean;
};
@@ -73,6 +75,8 @@ export function CourseForm({
registrationUrl: initial?.registrationUrl ?? "/register/",
posterImageUrl: initial?.posterImageUrl ?? "",
brochureImageUrl: initial?.brochureImageUrl ?? "",
leadHtml: initial?.leadHtml ?? "",
bodyHtml: initial?.bodyHtml ?? "",
seoDescription: initial?.seoDescription ?? "",
published: initial?.published ?? true,
});
@@ -176,7 +180,7 @@ export function CourseForm({
/>
</div>
<div className="space-y-1.5 sm:col-span-2">
<Label htmlFor="summary">خلاصه *</Label>
<Label htmlFor="summary">خلاصه کارت *</Label>
<Textarea
id="summary"
value={form.summary}
@@ -184,6 +188,33 @@ export function CourseForm({
required
rows={3}
/>
<p className="text-xs text-muted-foreground">
متن کوتاه برای کارت‌های فهرست؛ آگهی زیر عنوان جداگانه است.
</p>
</div>
<div className="space-y-1.5 sm:col-span-2">
<Label htmlFor="leadHtml">آگهی زیر عنوان (HTML)</Label>
<Textarea
id="leadHtml"
value={form.leadHtml}
onChange={(e) => set("leadHtml", e.target.value)}
rows={8}
className="font-mono text-xs"
placeholder="<p><strong>شعار</strong></p><p>متن آگهی…</p>"
dir="ltr"
/>
</div>
<div className="space-y-1.5 sm:col-span-2">
<Label htmlFor="bodyHtml">بدنه دوره (HTML)</Label>
<Textarea
id="bodyHtml"
value={form.bodyHtml}
onChange={(e) => set("bodyHtml", e.target.value)}
rows={12}
className="font-mono text-xs"
placeholder="<h2>درباره</h2><p>…</p><h2>سرفصل‌ها</h2><ol><li>…</li></ol>"
dir="ltr"
/>
</div>
</div>
</section>
@@ -7,6 +7,7 @@ import { TextLink } from "@/components/atoms/TextLink";
import { CourseMediaFigure } from "@/components/molecules/CourseMediaFigure";
import { DetailList, type DetailItem } from "@/components/molecules/DetailList";
import { PageHero } from "@/components/molecules/PageHero";
import { RichHtmlContent } from "@/components/molecules/RichHtmlContent";
import { SurfaceCard } from "@/components/molecules/SurfaceCard";
import { CourseRegisterGate } from "@/components/organisms/CourseRegisterGate";
import { Badge } from "@/components/ui/badge";
@@ -64,13 +65,20 @@ export function CourseDetailTemplate({
];
const hasTaxonomy = course.categories.length > 0 || course.tags.length > 0;
const brochureUrl = course.brochureImageUrl?.trim() || undefined;
const leadHtml = course.leadHtml?.trim() ?? "";
const bodyHtml = course.bodyHtml?.trim() ?? "";
const heroIntro = leadHtml ? (
<RichHtmlContent html={leadHtml} tone="onPrimary" />
) : (
course.summary
);
return (
<main id="main-content">
<JsonLd data={courseJsonLd(course)} />
<PageHero
title={course.title}
intro={course.summary}
intro={heroIntro}
eyebrow={course.categories[0]?.label ?? course.tags[0]?.label}
/>
@@ -87,14 +95,20 @@ export function CourseDetailTemplate({
/>
) : null}
<section className="space-y-4">
<Heading level={3} as="h2">
{labels.aboutTitle}
</Heading>
<p className="text-base leading-7 text-foreground/90">
{course.seoDescription || course.summary}
</p>
</section>
{bodyHtml || course.seoDescription ? (
<section className="space-y-4">
<Heading level={3} as="h2">
{labels.aboutTitle}
</Heading>
{bodyHtml ? (
<RichHtmlContent html={bodyHtml} />
) : (
<p className="text-base leading-7 text-foreground/90">
{course.seoDescription}
</p>
)}
</section>
) : null}
{hasTaxonomy ? (
<section className="space-y-4">