feat: major UI/UX overhaul, snippets system, and performance fixes
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Failing after 9m26s

This commit is contained in:
2026-02-16 12:31:40 +01:00
parent 6f62b37c3a
commit a5dba298f3
41 changed files with 1610 additions and 499 deletions

162
scripts/update-hobbies.js Normal file
View File

@@ -0,0 +1,162 @@
const fetch = require('node-fetch');
require('dotenv').config();
const DIRECTUS_URL = process.env.DIRECTUS_URL || 'https://cms.dk0.dev';
const DIRECTUS_TOKEN = process.env.DIRECTUS_STATIC_TOKEN;
async function syncHobbies() {
const hobbies = [
{
key: 'gym',
icon: 'Activity',
translations: [
{ languages_code: 'de-DE', title: 'Gym', description: 'Bin wieder regelmäßig im Training.' },
{ languages_code: 'en-US', title: 'Gym', description: 'Back at training regularly.' }
]
},
{
key: 'skiing',
icon: 'Activity',
translations: [
{ languages_code: 'de-DE', title: 'Skifahren', description: 'Ich liebe es, auf der Piste zu sein.' },
{ languages_code: 'en-US', title: 'Skiing', description: 'Love being out on the slopes.' }
]
},
{
key: 'programming',
icon: 'Code',
translations: [
{ languages_code: 'de-DE', title: 'Programmieren', description: 'Mache ich einfach gerne, auch privat.' },
{ languages_code: 'en-US', title: 'Programming', description: 'Just love building things, even in my free time.' }
]
},
{
key: 'reading',
icon: 'BookOpen',
translations: [
{ languages_code: 'de-DE', title: 'Lesen', description: 'Lese einfach gerne zur Entspannung.' },
{ languages_code: 'en-US', title: 'Reading', description: 'Enjoy reading to relax.' }
]
},
{
key: 'gaming',
icon: 'Gamepad2',
translations: [
{ languages_code: 'de-DE', title: 'Zocken', description: 'Ab und zu mal eine Runde zocken.' },
{ languages_code: 'en-US', title: 'Gaming', description: 'Playing some games every now and then.' }
]
},
{
key: 'series',
icon: 'Tv',
translations: [
{ languages_code: 'de-DE', title: 'Serien', description: 'Ich schaue gerne gute Serien.' },
{ languages_code: 'en-US', title: 'Series', description: 'I enjoy watching good series.' }
]
},
{
key: 'boardgames',
icon: 'Gamepad2',
translations: [
{ languages_code: 'de-DE', title: 'Gesellschaftsspiele', description: 'Mag Gesellschaftsspiele mit Freunden.' },
{ languages_code: 'en-US', title: 'Board Games', description: 'Love board games with friends.' }
]
},
{
key: 'traveling',
icon: 'Plane',
translations: [
{ languages_code: 'de-DE', title: 'Reisen', description: 'Ich reise einfach gerne.' },
{ languages_code: 'en-US', title: 'Traveling', description: 'I just love to travel.' }
]
},
{
key: 'analog_photography',
icon: 'Camera',
translations: [
{ languages_code: 'de-DE', title: 'Analoge Fotografie', description: 'Lese mich gerade in das Thema ein.' },
{ languages_code: 'en-US', title: 'Analog Photography', description: 'Currently reading into the topic.' }
]
},
{
key: 'astronomy',
icon: 'Stars',
translations: [
{ languages_code: 'de-DE', title: 'Astronomie', description: 'Fasziniert vom Universum und Sternen.' },
{ languages_code: 'en-US', title: 'Astronomy', description: 'Fascinated by the universe and stars.' }
]
},
{
key: 'guitar',
icon: 'Music',
translations: [
{ languages_code: 'de-DE', title: 'Gitarre', description: 'Spiele gelegentlich, wenn auch unregelmäßig.' },
{ languages_code: 'en-US', title: 'Guitar', description: 'Playing occasionally, even if not regularly.' }
]
}
];
console.log('🔄 Syncing hobbies to Directus...');
for (const hobby of hobbies) {
try {
const searchRes = await fetch(`${DIRECTUS_URL}/items/hobbies?filter[key][_eq]=${hobby.key}`, {
headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}` }
});
const searchData = await searchRes.json();
if (searchData.data && searchData.data.length > 0) {
const id = searchData.data[0].id;
console.log(`Updating ${hobby.key}...`);
await fetch(`${DIRECTUS_URL}/items/hobbies/${id}`, {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${DIRECTUS_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
status: 'published',
icon: hobby.icon,
translations: hobby.translations
})
});
} else {
console.log(`Creating ${hobby.key}...`);
await fetch(`${DIRECTUS_URL}/items/hobbies`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${DIRECTUS_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
key: hobby.key,
status: 'published',
icon: hobby.icon,
translations: hobby.translations
})
});
}
} catch (e) {
console.error(`Failed to sync ${hobby.key}:`, e.message);
}
}
// Delete 'gameServers' if it exists
try {
const delSearch = await fetch(`${DIRECTUS_URL}/items/hobbies?filter[key][_eq]=gameServers`, {
headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}` }
});
const delData = await delSearch.json();
if (delData.data && delData.data.length > 0) {
console.log('Removing gameServers hobby...');
await fetch(`${DIRECTUS_URL}/items/hobbies/${delData.data[0].id}`, {
method: 'DELETE',
headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}` }
});
}
} catch (e) {}
console.log('✅ Done!');
}
syncHobbies();