Fix FAQFull component: Migrate correct page ID (6), fix JSON-LD SSR and TS errors, remove justified-text
This commit is contained in:
@@ -7,6 +7,17 @@ import { getLocalizedSlugs } from '@intecion/ipal-kit'
|
||||
import { i18n } from '../../../../i18n.config'
|
||||
import { SetLanguageSlugs } from '../../../../components/LanguageSlugsProvider'
|
||||
import { RenderBlocks } from '../../../../blocks/RenderBlocks'
|
||||
import type { Page } from '../../../../payload-types'
|
||||
|
||||
type FAQFullBlock = Extract<NonNullable<Page['layout']>[0], { blockType: 'faqFull' }>
|
||||
|
||||
const PLACEHOLDER_PL = "Odpowiedź w przygotowaniu"
|
||||
const PLACEHOLDER_DE = "Antwort in Vorbereitung"
|
||||
|
||||
function isPlaceholder(answer: string | null | undefined): boolean {
|
||||
if (!answer) return true;
|
||||
return answer.includes(PLACEHOLDER_PL) || answer.includes(PLACEHOLDER_DE) || answer.includes('DO POTWIERDZENIA');
|
||||
}
|
||||
|
||||
export default async function Page(props: {
|
||||
params: Promise<{ locale: string; slug?: string[] }>
|
||||
@@ -47,8 +58,35 @@ export default async function Page(props: {
|
||||
|
||||
const layout = docForRender.layout || []
|
||||
|
||||
// Generowanie schematu FAQPage dla bloku faqFull (na poziomie Server Component gwarantuje to SSR)
|
||||
let faqSchema: Record<string, any> | null = null;
|
||||
const faqBlock = layout.find((b: any) => b.blockType === 'faqFull') as FAQFullBlock | undefined;
|
||||
if (faqBlock && faqBlock.questions) {
|
||||
const validQuestions = faqBlock.questions.filter((q: any) => !isPlaceholder(q.answer));
|
||||
if (validQuestions.length > 0) {
|
||||
faqSchema = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "FAQPage",
|
||||
"mainEntity": validQuestions.map((q: any) => ({
|
||||
"@type": "Question",
|
||||
"name": q.question,
|
||||
"acceptedAnswer": {
|
||||
"@type": "Answer",
|
||||
"text": q.answer
|
||||
}
|
||||
}))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="pt-8 pb-24">
|
||||
{faqSchema && (
|
||||
<script
|
||||
type="application/ld+json"
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(faqSchema) }}
|
||||
/>
|
||||
)}
|
||||
{/* Rejestracja zlokalizowanych slugów w globalnym kontekście dla LanguageSwitcher */}
|
||||
<SetLanguageSlugs slugs={slugs} />
|
||||
|
||||
@@ -59,7 +97,7 @@ export default async function Page(props: {
|
||||
)}
|
||||
|
||||
<main>
|
||||
<RenderBlocks blocks={layout} />
|
||||
<RenderBlocks blocks={layout} locale={locale} />
|
||||
</main>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user