diff --git a/views/admin/blog/edit.ejs b/views/admin/blog/edit.ejs index 80d46dd..838ed55 100644 --- a/views/admin/blog/edit.ejs +++ b/views/admin/blog/edit.ejs @@ -210,29 +210,31 @@
- -
-
+
<% categories.forEach(category=> { %> -
+
- > + > + for="category_<%= category._id %>"> + <%= category.name %> +
-
<% }); %>
-
Select one or more categories for this blog post.
+
Select one or more categories for this blog post. +
- -
-
+
<% tags.forEach(tag=> { %> -
+
- > - + > +
-
@@ -314,7 +319,8 @@ Mark as Featured Post
-
Featured posts can be highlighted on the blog page.
+
Featured posts can be highlighted on the blog + page.
@@ -371,27 +377,27 @@ try { <% if (blog.content) { %> - const blogContentRaw = <%- JSON.stringify(blog.content) %>; + const blogContentRaw = <% - JSON.stringify(blog.content) %>; if (blogContentRaw) { if (typeof blogContentRaw === 'string' && blogContentRaw.trim()) { // Try to parse as JSON string - try { + try { initialContentData = JSON.parse(blogContentRaw); // Validate it has blocks property if (!initialContentData.blocks || !Array.isArray(initialContentData.blocks)) { throw new Error('Invalid EditorJS format'); } - } catch (e) { + } catch (e) { // If not JSON, convert to EditorJS format - initialContentData = { - blocks: [{ - type: 'paragraph', - data: { + initialContentData = { + blocks: [{ + type: 'paragraph', + data: { text: blogContentRaw - } - }] - }; - } + } + }] + }; + } } else if (typeof blogContentRaw === 'object' && blogContentRaw !== null) { // Already an object, check if it's valid EditorJS format if (blogContentRaw.blocks && Array.isArray(blogContentRaw.blocks)) { @@ -416,27 +422,27 @@ try { <% if (blog.contentAfterQuote) { %> - const blogContentAfterQuoteRaw = <%- JSON.stringify(blog.contentAfterQuote) %>; + const blogContentAfterQuoteRaw = <% - JSON.stringify(blog.contentAfterQuote) %>; if (blogContentAfterQuoteRaw) { if (typeof blogContentAfterQuoteRaw === 'string' && blogContentAfterQuoteRaw.trim()) { // Try to parse as JSON string - try { + try { initialContentAfterQuoteData = JSON.parse(blogContentAfterQuoteRaw); // Validate it has blocks property if (!initialContentAfterQuoteData.blocks || !Array.isArray(initialContentAfterQuoteData.blocks)) { throw new Error('Invalid EditorJS format'); } - } catch (e) { + } catch (e) { // If not JSON, convert to EditorJS format - initialContentAfterQuoteData = { - blocks: [{ - type: 'paragraph', - data: { + initialContentAfterQuoteData = { + blocks: [{ + type: 'paragraph', + data: { text: blogContentAfterQuoteRaw - } - }] - }; - } + } + }] + }; + } } else if (typeof blogContentAfterQuoteRaw === 'object' && blogContentAfterQuoteRaw !== null) { // Already an object, check if it's valid EditorJS format if (blogContentAfterQuoteRaw.blocks && Array.isArray(blogContentAfterQuoteRaw.blocks)) { @@ -461,54 +467,54 @@ // Build tools object, only including plugins that are loaded const tools = { - header: { - class: Header, - config: { - levels: [2, 3, 4], - defaultLevel: 2 - } - }, - paragraph: { - class: Paragraph, - inlineToolbar: true - }, - list: { - class: List, - inlineToolbar: true, - config: { - defaultStyle: 'unordered' - } - }, - image: { - class: Image, - config: { - endpoints: { - byFile: '/admin/upload/image?imageType=blog' - } - } - }, - quote: { - class: Quote, - inlineToolbar: true, - shortcut: 'CMD+SHIFT+O', - config: { - quotePlaceholder: 'Enter a quote', - captionPlaceholder: 'Quote\'s author' - } - }, - marker: { - class: Marker, - shortcut: 'CMD+SHIFT+M' - }, - embed: { - class: Embed, - config: { - services: { - youtube: true, - vimeo: true - } - } + header: { + class: Header, + config: { + levels: [2, 3, 4], + defaultLevel: 2 + } + }, + paragraph: { + class: Paragraph, + inlineToolbar: true + }, + list: { + class: List, + inlineToolbar: true, + config: { + defaultStyle: 'unordered' + } + }, + image: { + class: Image, + config: { + endpoints: { + byFile: '/admin/upload/image?imageType=blog' } + } + }, + quote: { + class: Quote, + inlineToolbar: true, + shortcut: 'CMD+SHIFT+O', + config: { + quotePlaceholder: 'Enter a quote', + captionPlaceholder: 'Quote\'s author' + } + }, + marker: { + class: Marker, + shortcut: 'CMD+SHIFT+M' + }, + embed: { + class: Embed, + config: { + services: { + youtube: true, + vimeo: true + } + } + } }; // Add optional plugins if they're loaded @@ -750,7 +756,7 @@ const newCategoryInput = document.getElementById('newCategoryInput'); const categoriesContainer = document.getElementById('categoriesContainer'); - addCategoryBtn.addEventListener('click', async function() { + addCategoryBtn.addEventListener('click', async function () { const categoryName = newCategoryInput.value.trim(); if (!categoryName) { alert('Please enter a category name'); @@ -815,7 +821,7 @@ }); // Allow Enter key to add category - newCategoryInput.addEventListener('keypress', function(e) { + newCategoryInput.addEventListener('keypress', function (e) { if (e.key === 'Enter') { e.preventDefault(); addCategoryBtn.click(); @@ -827,7 +833,7 @@ const newTagInput = document.getElementById('newTagInput'); const tagsContainer = document.getElementById('tagsContainer'); - addTagBtn.addEventListener('click', async function() { + addTagBtn.addEventListener('click', async function () { const tagName = newTagInput.value.trim(); if (!tagName) { alert('Please enter a tag name'); @@ -891,7 +897,7 @@ }); // Allow Enter key to add tag - newTagInput.addEventListener('keypress', function(e) { + newTagInput.addEventListener('keypress', function (e) { if (e.key === 'Enter') { e.preventDefault(); addTagBtn.click(); @@ -902,8 +908,8 @@ -