fix: cleanup footer, smart navigation, and projects redesign

Removed aggressive background text in footer. Implemented intelligent back button for projects. Redesigned project archive page. Stabilized idle quote logic in activity feed.
This commit is contained in:
2026-02-16 01:35:35 +01:00
parent 7955dfbabb
commit 91eb446ac5
10 changed files with 176 additions and 2650 deletions

View File

@@ -1,123 +0,0 @@
#!/usr/bin/env node
/**
* Migrate Content Pages from PostgreSQL (Prisma) to Directus
*
* - Copies `content_pages` + translations from Postgres into Directus
* - Creates or updates items per (slug, locale)
*
* Usage:
* DATABASE_URL=postgresql://... DIRECTUS_STATIC_TOKEN=... DIRECTUS_URL=... \
* node scripts/migrate-content-pages-to-directus.js
*/
const fetch = require('node-fetch');
const { PrismaClient } = require('@prisma/client');
require('dotenv').config();
const DIRECTUS_URL = process.env.DIRECTUS_URL || 'https://cms.dk0.dev';
const DIRECTUS_TOKEN = process.env.DIRECTUS_STATIC_TOKEN;
if (!DIRECTUS_TOKEN) {
console.error('❌ Error: DIRECTUS_STATIC_TOKEN not found in env');
process.exit(1);
}
const prisma = new PrismaClient();
const localeMap = {
en: 'en-US',
de: 'de-DE',
};
function toDirectusLocale(locale) {
return localeMap[locale] || locale;
}
async function directusRequest(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 res = await fetch(url, options);
if (!res.ok) {
const text = await res.text();
throw new Error(`HTTP ${res.status} on ${endpoint}: ${text}`);
}
return res.json();
}
async function upsertContentIntoDirectus({ slug, locale, status, title, content }) {
const directusLocale = toDirectusLocale(locale);
// allow locale-specific slug variants: base for en, base-locale for others
const slugVariant = directusLocale === 'en-US' ? slug : `${slug}-${directusLocale.toLowerCase()}`;
const payload = {
slug: slugVariant,
locale: directusLocale,
status: status?.toLowerCase?.() === 'published' ? 'published' : status || 'draft',
title: title || slug,
content: content || null,
};
try {
const { data } = await directusRequest('items/content_pages', 'POST', payload);
console.log(` Created ${slugVariant} (${directusLocale}) [id=${data?.id}]`);
return data?.id;
} catch (error) {
const msg = error?.message || '';
if (msg.includes('already exists') || msg.includes('duplicate key') || msg.includes('UNIQUE')) {
console.log(` ⚠️ Skipping ${slugVariant} (${directusLocale}) already exists`);
return null;
}
throw error;
}
}
async function migrateContentPages() {
console.log('\n📦 Migrating Content Pages from PostgreSQL to Directus...');
const pages = await prisma.contentPage.findMany({
include: { translations: true },
});
console.log(`Found ${pages.length} pages in PostgreSQL`);
for (const page of pages) {
const status = page.status || 'PUBLISHED';
for (const tr of page.translations) {
await upsertContentIntoDirectus({
slug: page.key,
locale: tr.locale,
status,
title: tr.title,
content: tr.content,
});
}
}
console.log('✅ Content page migration finished.');
}
async function main() {
try {
await prisma.$connect();
await migrateContentPages();
} catch (error) {
console.error('❌ Migration failed:', error.message);
process.exit(1);
} finally {
await prisma.$disconnect();
}
}
main();

View File

@@ -1,185 +0,0 @@
#!/usr/bin/env node
/**
* Migrate Hobbies to Directus
*
* Migriert Hobbies-Daten aus messages/en.json und messages/de.json nach Directus
*
* Usage:
* node scripts/migrate-hobbies-to-directus.js
*/
const fetch = require('node-fetch');
const fs = require('fs');
const path = require('path');
require('dotenv').config();
const DIRECTUS_URL = process.env.DIRECTUS_URL || 'https://cms.dk0.dev';
const DIRECTUS_TOKEN = process.env.DIRECTUS_STATIC_TOKEN;
if (!DIRECTUS_TOKEN) {
console.error('❌ Error: DIRECTUS_STATIC_TOKEN not found in .env');
process.exit(1);
}
const messagesEn = JSON.parse(
fs.readFileSync(path.join(__dirname, '../messages/en.json'), 'utf-8')
);
const messagesDe = JSON.parse(
fs.readFileSync(path.join(__dirname, '../messages/de.json'), 'utf-8')
);
const hobbiesEn = messagesEn.home.about.hobbies;
const hobbiesDe = messagesDe.home.about.hobbies;
const HOBBIES_DATA = [
{
key: 'self_hosting',
icon: 'Code',
titleEn: hobbiesEn.selfHosting,
titleDe: hobbiesDe.selfHosting
},
{
key: 'gaming',
icon: 'Gamepad2',
titleEn: hobbiesEn.gaming,
titleDe: hobbiesDe.gaming
},
{
key: 'game_servers',
icon: 'Server',
titleEn: hobbiesEn.gameServers,
titleDe: hobbiesDe.gameServers
},
{
key: 'jogging',
icon: 'Activity',
titleEn: hobbiesEn.jogging,
titleDe: hobbiesDe.jogging
}
];
async function directusRequest(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);
}
try {
const response = await fetch(url, options);
if (!response.ok) {
const text = await response.text();
throw new Error(`HTTP ${response.status}: ${text}`);
}
return await response.json();
} catch (error) {
console.error(`Error calling ${method} ${endpoint}:`, error.message);
throw error;
}
}
async function migrateHobbies() {
console.log('\n📦 Migrating Hobbies to Directus...\n');
for (const hobby of HOBBIES_DATA) {
console.log(`\n🎮 Hobby: ${hobby.key}`);
try {
// 1. Create Hobby
console.log(' Creating hobby...');
const hobbyData = {
key: hobby.key,
icon: hobby.icon,
status: 'published',
sort: HOBBIES_DATA.indexOf(hobby) + 1
};
const { data: createdHobby } = await directusRequest(
'items/hobbies',
'POST',
hobbyData
);
console.log(` ✅ Hobby created with ID: ${createdHobby.id}`);
// 2. Create Translations
console.log(' Creating translations...');
// English Translation
await directusRequest(
'items/hobbies_translations',
'POST',
{
hobbies_id: createdHobby.id,
languages_code: 'en-US',
title: hobby.titleEn
}
);
// German Translation
await directusRequest(
'items/hobbies_translations',
'POST',
{
hobbies_id: createdHobby.id,
languages_code: 'de-DE',
title: hobby.titleDe
}
);
console.log(' ✅ Translations created (en-US, de-DE)');
} catch (error) {
console.error(` ❌ Error migrating ${hobby.key}:`, error.message);
}
}
console.log('\n✨ Migration complete!\n');
}
async function verifyMigration() {
console.log('\n🔍 Verifying Migration...\n');
try {
const { data: hobbies } = await directusRequest(
'items/hobbies?fields=key,icon,status,translations.title,translations.languages_code'
);
console.log(`✅ Found ${hobbies.length} hobbies in Directus:`);
hobbies.forEach(h => {
const enTitle = h.translations?.find(t => t.languages_code === 'en-US')?.title;
console.log(` - ${h.key}: "${enTitle}"`);
});
console.log('\n🎉 Hobbies successfully migrated!\n');
console.log('Next steps:');
console.log(' 1. Visit: https://cms.dk0.dev/admin/content/hobbies');
console.log(' 2. Update About.tsx to load hobbies from Directus\n');
} catch (error) {
console.error('❌ Verification failed:', error.message);
}
}
async function main() {
console.log('\n╔════════════════════════════════════════╗');
console.log('║ Hobbies Migration to Directus ║');
console.log('╚════════════════════════════════════════╝\n');
try {
await migrateHobbies();
await verifyMigration();
} catch (error) {
console.error('\n❌ Migration failed:', error);
process.exit(1);
}
}
main();

View File

@@ -1,240 +0,0 @@
#!/usr/bin/env node
/**
* Directus Tech Stack Migration Script
*
* Migriert bestehende Tech Stack Daten aus messages/en.json und messages/de.json
* nach Directus Collections.
*
* Usage:
* npm install node-fetch@2 dotenv
* node scripts/migrate-tech-stack-to-directus.js
*/
const fetch = require('node-fetch');
const fs = require('fs');
const path = require('path');
require('dotenv').config();
const DIRECTUS_URL = process.env.DIRECTUS_URL || 'https://cms.dk0.dev';
const DIRECTUS_TOKEN = process.env.DIRECTUS_STATIC_TOKEN;
if (!DIRECTUS_TOKEN) {
console.error('❌ Error: DIRECTUS_STATIC_TOKEN not found in .env');
process.exit(1);
}
// Lade aktuelle Tech Stack Daten aus messages files
const messagesEn = JSON.parse(
fs.readFileSync(path.join(__dirname, '../messages/en.json'), 'utf-8')
);
const messagesDe = JSON.parse(
fs.readFileSync(path.join(__dirname, '../messages/de.json'), 'utf-8')
);
const techStackEn = messagesEn.home.about.techStack;
const techStackDe = messagesDe.home.about.techStack;
// Tech Stack Struktur aus About.tsx
const TECH_STACK_DATA = [
{
key: 'frontend',
icon: 'Globe',
nameEn: techStackEn.categories.frontendMobile,
nameDe: techStackDe.categories.frontendMobile,
items: ['Next.js', 'Tailwind CSS', 'Flutter']
},
{
key: 'backend',
icon: 'Server',
nameEn: techStackEn.categories.backendDevops,
nameDe: techStackDe.categories.backendDevops,
items: ['Docker', 'PostgreSQL', 'Redis', 'Traefik']
},
{
key: 'tools',
icon: 'Wrench',
nameEn: techStackEn.categories.toolsAutomation,
nameDe: techStackDe.categories.toolsAutomation,
items: ['Git', 'CI/CD', 'n8n', techStackEn.items.selfHostedServices]
},
{
key: 'security',
icon: 'Shield',
nameEn: techStackEn.categories.securityAdmin,
nameDe: techStackDe.categories.securityAdmin,
items: ['CrowdSec', 'Suricata', 'Proxmox']
}
];
async function directusRequest(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);
}
try {
const response = await fetch(url, options);
if (!response.ok) {
const text = await response.text();
throw new Error(`HTTP ${response.status}: ${text}`);
}
return await response.json();
} catch (error) {
console.error(`Error calling ${method} ${endpoint}:`, error.message);
throw error;
}
}
async function ensureLanguagesExist() {
console.log('\n🌍 Checking Languages...');
try {
const { data: languages } = await directusRequest('items/languages');
const hasEnUS = languages.some(l => l.code === 'en-US');
const hasDeDE = languages.some(l => l.code === 'de-DE');
if (!hasEnUS) {
console.log(' Creating en-US language...');
await directusRequest('items/languages', 'POST', {
code: 'en-US',
name: 'English (United States)'
});
}
if (!hasDeDE) {
console.log(' Creating de-DE language...');
await directusRequest('items/languages', 'POST', {
code: 'de-DE',
name: 'German (Germany)'
});
}
console.log(' ✅ Languages ready');
} catch (error) {
console.log(' ⚠️ Languages collection might not exist yet');
}
}
async function migrateTechStack() {
console.log('\n📦 Migrating Tech Stack to Directus...\n');
await ensureLanguagesExist();
for (const category of TECH_STACK_DATA) {
console.log(`\n📁 Category: ${category.key}`);
try {
// 1. Create Category
console.log(' Creating category...');
const categoryData = {
key: category.key,
icon: category.icon,
status: 'published',
sort: TECH_STACK_DATA.indexOf(category) + 1
};
const { data: createdCategory } = await directusRequest(
'items/tech_stack_categories',
'POST',
categoryData
);
console.log(` ✅ Category created with ID: ${createdCategory.id}`);
// 2. Create Translations
console.log(' Creating translations...');
// English Translation
await directusRequest(
'items/tech_stack_categories_translations',
'POST',
{
tech_stack_categories_id: createdCategory.id,
languages_code: 'en-US',
name: category.nameEn
}
);
// German Translation
await directusRequest(
'items/tech_stack_categories_translations',
'POST',
{
tech_stack_categories_id: createdCategory.id,
languages_code: 'de-DE',
name: category.nameDe
}
);
console.log(' ✅ Translations created (en-US, de-DE)');
// 3. Create Items
console.log(` Creating ${category.items.length} items...`);
for (let i = 0; i < category.items.length; i++) {
const itemName = category.items[i];
await directusRequest(
'items/tech_stack_items',
'POST',
{
category: createdCategory.id,
name: itemName,
sort: i + 1
}
);
console.log(`${itemName}`);
}
} catch (error) {
console.error(` ❌ Error migrating ${category.key}:`, error.message);
}
}
console.log('\n✨ Migration complete!\n');
}
async function verifyMigration() {
console.log('\n🔍 Verifying Migration...\n');
try {
const { data: categories } = await directusRequest(
'items/tech_stack_categories?fields=*,translations.*,items.*'
);
console.log(`✅ Found ${categories.length} categories:`);
categories.forEach(cat => {
const enTranslation = cat.translations?.find(t => t.languages_code === 'en-US');
const itemCount = cat.items?.length || 0;
console.log(` - ${cat.key}: "${enTranslation?.name}" (${itemCount} items)`);
});
console.log('\n🎉 All data migrated successfully!\n');
console.log('Next steps:');
console.log(' 1. Visit https://cms.dk0.dev/admin/content/tech_stack_categories');
console.log(' 2. Verify data looks correct');
console.log(' 3. Run: npm run dev:directus (to test GraphQL queries)');
console.log(' 4. Update About.tsx to use Directus data\n');
} catch (error) {
console.error('❌ Verification failed:', error.message);
}
}
// Main execution
(async () => {
try {
await migrateTechStack();
await verifyMigration();
} catch (error) {
console.error('\n❌ Migration failed:', error);
process.exit(1);
}
})();