diff --git a/apps/data-panel/renderer/app.js b/apps/data-panel/renderer/app.js index 78df45a..b1a9ab0 100644 --- a/apps/data-panel/renderer/app.js +++ b/apps/data-panel/renderer/app.js @@ -1,5 +1,5 @@ -import { COLLECTION_CONFIGS, PODCAST_LABELS } from "./configs.js"; +import { BLOG_CATEGORIES, COLLECTION_CONFIGS, PODCAST_LABELS } from "./configs.js"; const state = { activeTab: "blog", @@ -136,6 +136,23 @@ function emptyBlogDraft() { }; } +function ensureBlogCategorySelect(selectedCategory = "General") { + const options = BLOG_CATEGORIES; + const normalizedSelected = String(selectedCategory || "").trim(); + const hasSelected = options.includes(normalizedSelected); + const finalValue = hasSelected ? normalizedSelected : "General"; + + el.blogCategory.innerHTML = ""; + for (const category of options) { + const option = document.createElement("option"); + option.value = category; + option.textContent = category; + el.blogCategory.appendChild(option); + } + + el.blogCategory.value = finalValue; +} + function currentBlogDraft() { return { slug: el.blogSlug.value.trim(), @@ -154,7 +171,7 @@ function fillBlogForm(post) { const draft = post || emptyBlogDraft(); el.blogSlug.value = draft.slug || ""; el.blogTitle.value = draft.title || ""; - el.blogCategory.value = draft.category || "General"; + ensureBlogCategorySelect(draft.category || "General"); el.blogDate.value = draft.date || ""; el.blogReadTime.value = draft.readTime || ""; el.blogAuthor.value = draft.author || "Poyraz Avsever"; diff --git a/apps/data-panel/renderer/configs.js b/apps/data-panel/renderer/configs.js index a48dd61..d6e771e 100644 --- a/apps/data-panel/renderer/configs.js +++ b/apps/data-panel/renderer/configs.js @@ -1,4 +1,6 @@ +export const BLOG_CATEGORIES = ["Frontend", "UX", "Yazilim", "TypeScript", "Testing", "General"]; + export const COLLECTION_CONFIGS = { announcement: { label: "Announcement", diff --git a/apps/data-panel/renderer/index.html b/apps/data-panel/renderer/index.html index 8edf16a..8f248f7 100644 --- a/apps/data-panel/renderer/index.html +++ b/apps/data-panel/renderer/index.html @@ -66,7 +66,7 @@
- +
diff --git a/components/projects-content.tsx b/components/projects-content.tsx index 39ffe13..d7db257 100644 --- a/components/projects-content.tsx +++ b/components/projects-content.tsx @@ -80,7 +80,7 @@ export async function ProjectsContent() { - +