Browse Source

fix generating description md content if feedline is exist in textarea

weichen 3 years ago
parent
commit
819d7d9f09
1 changed files with 12 additions and 2 deletions
  1. 12 2
      backstage/static/js/editor.js

+ 12 - 2
backstage/static/js/editor.js

@@ -20,10 +20,20 @@ axios.get(contentApiUrl).then(({ data }) => {
       mdContent += frontMatter + '\n';
     }
     for (var idx=0; idx<blockArray.length; idx++) {
-      mdContent += `\n### **${_.get(blockArray[idx], 'title', '')}**\n`
+      if (_.get(blockArray[idx], 'title', '').includes('敘述')) {
+        mdContent += `\n<!-- ### **${_.get(blockArray[idx], 'title', '')}**-->\n`
+      } else {
+        mdContent += `\n### **${_.get(blockArray[idx], 'title', '')}**\n`
+      }
       for (var data of _.get(blockArray[idx], 'data', [])) {
         if (_.get(_.keys(data), 0) === 'description') {
-          mdContent += `\n${_.get(data, 'description.text', '')}`;
+          if (_.get(data, 'description.text', '').includes('\n')) {
+            for (const line of _.get(data, 'description.text', '').split('\n')) {
+              mdContent += `\n${line}    `;
+            }
+          } else {
+            mdContent += `\n${_.get(data, 'description.text', '')}`;
+          }
         } else if (_.get(_.keys(data), 0) === 'image') {
           ampImgForm = `\n<amp-img\
 \n  alt="${_.get(data, 'image.alt', '小寶優居')}"\