Automated CMS content seeding, integrated interactive AI Chat into Bento grid, implemented intelligent idle quote logic, and unified editorial styling across all sub-pages.
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
#!/usr/bin/env node
|
|
require('dotenv').config();
|
|
const DIRECTUS_URL = process.env.DIRECTUS_URL || 'https://cms.dk0.dev';
|
|
const DIRECTUS_TOKEN = process.env.DIRECTUS_STATIC_TOKEN;
|
|
|
|
async function api(endpoint, method = 'POST', body = null) {
|
|
const res = await fetch(`${DIRECTUS_URL}/${endpoint}`, {
|
|
method,
|
|
headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}`, 'Content-Type': 'application/json' },
|
|
body: body ? JSON.stringify(body) : null
|
|
});
|
|
const data = await res.json().catch(() => ({}));
|
|
return { ok: res.ok, data };
|
|
}
|
|
|
|
async function fixMessagesCollection() {
|
|
console.log('🛠 Repariere "messages" Collection...');
|
|
|
|
// 1. Key-Feld hinzufügen (falls es fehlt)
|
|
// Wir nutzen type: string und schema: {} um eine echte Spalte zu erzeugen
|
|
const fieldRes = await api('fields/messages', 'POST', {
|
|
field: 'key',
|
|
type: 'string',
|
|
schema: {
|
|
is_nullable: false,
|
|
is_unique: true
|
|
},
|
|
meta: {
|
|
interface: 'input',
|
|
options: { placeholder: 'z.B. hero.title' },
|
|
required: true
|
|
}
|
|
});
|
|
|
|
if (fieldRes.ok) {
|
|
console.log('✅ "key" Feld erfolgreich erstellt.');
|
|
} else {
|
|
console.log('⚠️ "key" Feld konnte nicht erstellt werden (existiert evtl schon).');
|
|
}
|
|
|
|
// 2. Übersetzungs-Feld in der Untertabelle reparieren
|
|
console.log('🛠 Prüfe messages_translations...');
|
|
await api('fields/messages_translations', 'POST', {
|
|
field: 'value',
|
|
type: 'text',
|
|
schema: {},
|
|
meta: { interface: 'input-multiline' }
|
|
}).catch(() => {});
|
|
|
|
console.log('✅ Fix abgeschlossen! Bitte lade Directus neu.');
|
|
}
|
|
|
|
fixMessagesCollection().catch(console.error);
|