Load home portfolio views from API; improve resume PDF layout
Stop hardcoding deleted audience views and re-seeding them on boot. Tighten resume print CSS with professional fonts and page-break rules for a cleaner 1–2 page Letter PDF.
This commit is contained in:
+45
-55
@@ -39,66 +39,56 @@ async function main() {
|
||||
};
|
||||
// We keep canonical slugs; PortfolioView can use short names
|
||||
|
||||
console.log("Seeding default portfolio views…");
|
||||
const cats = await prisma.category.findMany();
|
||||
const bySlug = Object.fromEntries(cats.map((c) => [c.slug, c]));
|
||||
// Seed portfolio views only on a fresh DB. Do not re-create views after the admin deletes them.
|
||||
const viewCount = await prisma.portfolioView.count();
|
||||
if (viewCount === 0) {
|
||||
console.log("Seeding default portfolio views (empty table)…");
|
||||
const cats = await prisma.category.findMany();
|
||||
const bySlug = Object.fromEntries(cats.map((c) => [c.slug, c]));
|
||||
|
||||
async function upsertView(
|
||||
name: string,
|
||||
viewSlug: string,
|
||||
description: string,
|
||||
orderedSlugs: string[]
|
||||
) {
|
||||
const view = await prisma.portfolioView.upsert({
|
||||
where: { slug: viewSlug },
|
||||
create: { name, slug: viewSlug, description, showOthers: true },
|
||||
update: { name, description },
|
||||
});
|
||||
await prisma.portfolioViewCategory.deleteMany({ where: { viewId: view.id } });
|
||||
for (let i = 0; i < orderedSlugs.length; i++) {
|
||||
const cat = bySlug[orderedSlugs[i]];
|
||||
if (!cat) continue;
|
||||
await prisma.portfolioViewCategory.create({
|
||||
data: { viewId: view.id, categoryId: cat.id, priority: i },
|
||||
async function createView(
|
||||
name: string,
|
||||
viewSlug: string,
|
||||
description: string,
|
||||
orderedSlugs: string[]
|
||||
) {
|
||||
const view = await prisma.portfolioView.create({
|
||||
data: { name, slug: viewSlug, description, showOthers: true },
|
||||
});
|
||||
for (let i = 0; i < orderedSlugs.length; i++) {
|
||||
const cat = bySlug[orderedSlugs[i]];
|
||||
if (!cat) continue;
|
||||
await prisma.portfolioViewCategory.create({
|
||||
data: { viewId: view.id, categoryId: cat.id, priority: i },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await upsertView(
|
||||
"Game Development",
|
||||
"game-dev",
|
||||
"Work prioritized for game studios and interactive media.",
|
||||
["3d-animation", "3d-modeling", "3d-sculpting", "ai-generated-content", "cad"]
|
||||
);
|
||||
await upsertView(
|
||||
"Engineering",
|
||||
"engineering",
|
||||
"Work prioritized for engineering and product teams.",
|
||||
["cad", "3d-modeling", "illustration", "graphic-design"]
|
||||
);
|
||||
await upsertView(
|
||||
"3D",
|
||||
"3d",
|
||||
"All 3D work front and center.",
|
||||
["3d-modeling", "3d-animation", "3d-sculpting", "cad"]
|
||||
);
|
||||
await upsertView("Animation", "animation", "Animation-focused portfolio.", [
|
||||
"3d-animation",
|
||||
"video",
|
||||
]);
|
||||
await upsertView("CAD", "cad", "CAD and technical design.", ["cad", "3d-modeling"]);
|
||||
await upsertView("AI", "ai", "AI-generated creative work.", [
|
||||
"ai-generated-content",
|
||||
"illustration",
|
||||
"graphic-design",
|
||||
]);
|
||||
|
||||
// Shorter category filter aliases as views that just prioritize that category
|
||||
for (const [canonical, short] of Object.entries(aliases)) {
|
||||
if (short === "3d" || short === "animation" || short === "ai") continue;
|
||||
await upsertView(bySlug[canonical]?.name ?? short, short, `Filter: ${short}`, [
|
||||
canonical,
|
||||
await createView(
|
||||
"3D",
|
||||
"3d",
|
||||
"All 3D work front and center.",
|
||||
["3d-modeling", "3d-animation", "3d-sculpting", "cad"]
|
||||
);
|
||||
await createView("Animation", "animation", "Animation-focused portfolio.", [
|
||||
"3d-animation",
|
||||
"video",
|
||||
]);
|
||||
await createView("CAD", "cad", "CAD and technical design.", ["cad", "3d-modeling"]);
|
||||
await createView("AI", "ai", "AI-generated creative work.", [
|
||||
"ai-generated-content",
|
||||
"illustration",
|
||||
"graphic-design",
|
||||
]);
|
||||
|
||||
for (const [canonical, short] of Object.entries(aliases)) {
|
||||
if (short === "3d" || short === "animation" || short === "ai") continue;
|
||||
await createView(bySlug[canonical]?.name ?? short, short, `Filter: ${short}`, [
|
||||
canonical,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
console.log(`Skipping portfolio view seed (${viewCount} existing views).`);
|
||||
}
|
||||
|
||||
const existingResume = await prisma.resume.findFirst({ where: { isActive: true } });
|
||||
|
||||
Reference in New Issue
Block a user