+
@@ -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 @@
-
+
-
Are you sure you want to delete the category ""?
+
Are you sure you want to delete the category ""?
+
This action cannot be undone.
@@ -961,16 +968,19 @@
@@ -989,7 +999,7 @@
let currentCategoryBtn = null;
// Handle category delete buttons
- document.addEventListener('click', function(e) {
+ document.addEventListener('click', function (e) {
if (e.target.closest('.delete-category-btn')) {
e.preventDefault();
const btn = e.target.closest('.delete-category-btn');
@@ -1006,7 +1016,7 @@
});
// Handle confirm delete category
- document.getElementById('confirmDeleteCategoryBtn').addEventListener('click', async function() {
+ document.getElementById('confirmDeleteCategoryBtn').addEventListener('click', async function () {
if (!currentCategoryId || !currentCategoryBtn) return;
const btn = currentCategoryBtn;
@@ -1070,7 +1080,7 @@
let currentTagBtn = null;
// Handle tag delete buttons
- document.addEventListener('click', function(e) {
+ document.addEventListener('click', function (e) {
if (e.target.closest('.delete-tag-btn')) {
e.preventDefault();
const btn = e.target.closest('.delete-tag-btn');
@@ -1087,7 +1097,7 @@
});
// Handle confirm delete tag
- document.getElementById('confirmDeleteTagBtn').addEventListener('click', async function() {
+ document.getElementById('confirmDeleteTagBtn').addEventListener('click', async function () {
if (!currentTagId || !currentTagBtn) return;
const btn = currentTagBtn;
diff --git a/views/admin/blog/index.ejs b/views/admin/blog/index.ejs
index 037ea7f..68adadb 100644
--- a/views/admin/blog/index.ejs
+++ b/views/admin/blog/index.ejs
@@ -136,21 +136,21 @@
- <% if (typeof frontendUrl !== 'undefined') { %>
+ <% if (typeof frontendUrl !=='undefined' ) { %>
View
- <% } %>
-
- Edit
-
-
+ <% } %>
+
+ Edit
+
+
|