Parcourir la source

fix draft value

SyuanYu il y a 2 ans
Parent
commit
809dac737c
2 fichiers modifiés avec 10 ajouts et 2 suppressions
  1. 1 1
      backstage/static/js/editor.js
  2. 9 1
      backstage/static/js/yo.js

+ 1 - 1
backstage/static/js/editor.js

@@ -314,7 +314,7 @@ function editorSave() {
       .save()
       .then((outputData) => {
         //var articleinfo = frontMatters.join('\n');
-        var articleinfo = GetMdHeader();
+        var articleinfo = GetMdHeader("editorSave");
         var mdContent = '<div class="container-fluid blog_article p-0">\n\n';
         //var headings = new Array();
 

+ 9 - 1
backstage/static/js/yo.js

@@ -287,6 +287,7 @@ function writeMd() {
               content: mdContent,
               url: editTarget,
             };
+
             axios
               .post(contentApiUrl + editTarget, (json = postData))
               .then(({ data }) => {});
@@ -630,7 +631,14 @@ function GetMdHeader(result = []) {
   rContent += 'meta_description: "' + $("#cmetadsc").val() + '"\n';
   rContent += 'title: "' + $("#ctitle").val() + '"\n';
   rContent += "date: " + $("#cdate").val() + "\n";
-  rContent += "draft: " + $("#cdraft").is(":checked") + "\n";
+  // rContent += "draft: " + !$("#cdraft").is(":checked") + "\n";
+
+  // 點擊編輯完成後勾選顯示
+  if (result === "editorSave" || result !== []) {
+    rContent += "draft: " + false + "\n";
+  } else {
+    rContent += "draft: " + !$("#cdraft").is(":checked") + "\n";
+  }
 
   if ($("#ctype").val() == "news") {
     rContent += 'display: ' + $("#cdisplay").is(":checked") + '\n';