83 lines
2.1 KiB
JavaScript
83 lines
2.1 KiB
JavaScript
const BASE_URL = process.env.PAYLOAD_API_URL || 'http://localhost:3000'
|
|
const API_KEY = process.env.PAYLOAD_API_KEY
|
|
const headers = { 'Content-Type': 'application/json', Authorization: `users API-Key ${API_KEY}` }
|
|
let i = 0
|
|
|
|
async function tryPage(label, layout) {
|
|
i++
|
|
const res = await fetch(`${BASE_URL}/api/pages?locale=sv`, {
|
|
method: 'POST', headers,
|
|
body: JSON.stringify({ title: `Debug ${i}`, slug: `debug-${i}`, layout, _status: 'draft' }),
|
|
})
|
|
const json = await res.json()
|
|
if (!res.ok) console.log(`❌ ${label}:\n${JSON.stringify(json, null, 2)}`)
|
|
else console.log(`✅ ${label}`)
|
|
}
|
|
|
|
// --- CtaBanner variants ---
|
|
await tryPage('Banner: minimal', [{
|
|
blockType: 'lmCtaBanner',
|
|
heading: 'Test',
|
|
sectionBackground: 'dark',
|
|
alignment: 'center',
|
|
size: 'large',
|
|
}])
|
|
|
|
await tryPage('Banner: with cta fields', [{
|
|
blockType: 'lmCtaBanner',
|
|
heading: 'Test',
|
|
ctaText: 'Go',
|
|
ctaLink: '/contact',
|
|
sectionBackground: 'dark',
|
|
alignment: 'center',
|
|
size: 'large',
|
|
}])
|
|
|
|
// --- CardGrid variants ---
|
|
await tryPage('CardGrid: minimal 1 card no contentLines', [{
|
|
blockType: 'lmCardGrid',
|
|
layout: '1-1-1',
|
|
cardStyle: 'dark',
|
|
sectionBackground: 'dark',
|
|
cards: [{ displayMode: 'centeredHeading', heading: 'Card 1' }],
|
|
}])
|
|
|
|
await tryPage('CardGrid: content mode with contentLines', [{
|
|
blockType: 'lmCardGrid',
|
|
layout: '1-1-1',
|
|
cardStyle: 'dark',
|
|
sectionBackground: 'dark',
|
|
cards: [{
|
|
displayMode: 'content',
|
|
heading: 'Card 1',
|
|
contentLines: [{ text: 'Line one', style: 'normal' }],
|
|
}],
|
|
}])
|
|
|
|
// --- USP Checklist ---
|
|
await tryPage('USP: textColor white', [{
|
|
blockType: 'lmUspChecklist',
|
|
heading: 'Why us',
|
|
items: [{ text: 'Item one' }],
|
|
checkColor: 'yellow',
|
|
sectionBackground: 'dark',
|
|
textColor: 'white',
|
|
}])
|
|
|
|
await tryPage('USP: no textColor', [{
|
|
blockType: 'lmUspChecklist',
|
|
heading: 'Why us',
|
|
items: [{ text: 'Item one' }],
|
|
checkColor: 'yellow',
|
|
sectionBackground: 'dark',
|
|
}])
|
|
|
|
await tryPage('USP: textColor navy', [{
|
|
blockType: 'lmUspChecklist',
|
|
heading: 'Why us',
|
|
items: [{ text: 'Item one' }],
|
|
checkColor: 'yellow',
|
|
sectionBackground: 'dark',
|
|
textColor: 'navy',
|
|
}])
|