Refactor for i18n, CMS integration, and project slugs; enhance admin & analytics
Co-authored-by: dennis <dennis@konkol.net>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { slugify } from "../lib/slug";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
@@ -947,10 +948,21 @@ Visit any non-existent page on the site to see the terminal in action. Or click
|
||||
},
|
||||
];
|
||||
|
||||
const usedSlugs = new Set<string>();
|
||||
for (const project of projects) {
|
||||
const baseSlug = slugify(project.title);
|
||||
let slug = baseSlug;
|
||||
let counter = 2;
|
||||
while (usedSlugs.has(slug) || !slug) {
|
||||
slug = `${baseSlug || "project"}-${counter++}`;
|
||||
}
|
||||
usedSlugs.add(slug);
|
||||
|
||||
await prisma.project.create({
|
||||
data: {
|
||||
...project,
|
||||
slug,
|
||||
defaultLocale: "en",
|
||||
difficulty: project.difficulty as
|
||||
| "BEGINNER"
|
||||
| "INTERMEDIATE"
|
||||
|
||||
Reference in New Issue
Block a user