Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Has been cancelled
61 lines
1.8 KiB
JavaScript
61 lines
1.8 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 = 'GET', body = null) {
|
|
const url = `${DIRECTUS_URL}/${endpoint}`;
|
|
const options = {
|
|
method,
|
|
headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}`, 'Content-Type': 'application/json' }
|
|
};
|
|
if (body) options.body = JSON.stringify(body);
|
|
const response = await fetch(url, options);
|
|
const data = await response.json();
|
|
return { ok: response.ok, data };
|
|
}
|
|
|
|
async function finalCleanup() {
|
|
console.log('🧹 Räume Directus UI auf...');
|
|
|
|
// 1. Haupt-Collection konfigurieren
|
|
await api('collections/book_reviews', 'PATCH', {
|
|
meta: {
|
|
icon: 'import_contacts',
|
|
display_template: '{{book_title}}',
|
|
hidden: false,
|
|
group: null, // Aus Ordnern herausholen
|
|
singleton: false,
|
|
translations: [
|
|
{ language: 'de-DE', translation: 'Buch-Bewertungen' },
|
|
{ language: 'en-US', translation: 'Book Reviews' }
|
|
]
|
|
}
|
|
});
|
|
|
|
// 2. Übersetzungs-Tabelle verstecken (Wichtig für die Optik!)
|
|
await api('collections/book_reviews_translations', 'PATCH', {
|
|
meta: {
|
|
hidden: true,
|
|
group: 'book_reviews' // Technisch untergeordnet
|
|
}
|
|
});
|
|
|
|
// 3. Sicherstellen, dass das 'translations' Feld im CMS gut aussieht
|
|
await api('fields/book_reviews/translations', 'PATCH', {
|
|
meta: {
|
|
interface: 'translations',
|
|
display: 'translations',
|
|
options: {
|
|
languageField: 'languages_code',
|
|
userLanguage: true
|
|
}
|
|
}
|
|
});
|
|
|
|
console.log('✅ UI optimiert! Bitte lade Directus jetzt neu (Cmd+R / Strg+R).');
|
|
console.log('Du solltest jetzt links in der Navigation "Book Reviews" mit einem Buch-Icon sehen.');
|
|
}
|
|
|
|
finalCleanup().catch(console.error);
|