Action

New Hugo Blog

Posted by Nicked, Last update almost 2 years ago

UPDATES

almost 2 years ago

fix time issue

Create a new draft for the blog header of Hugo.

Steps

  • script

    // See online documentation for examples
    // https://docs.getdrafts.com/docs/actions/scripting
    
    function at(s){
      if(s<10)
        s="0"+s
      return s
    }
    
    var now = new Date();
    var hh =now.getHours();
    var mm = now.getMinutes();
    var ss = now.getSeconds();
    var y = now.getFullYear();
    var m = now.getMonth()+1;
    var d = now.getDate();
    var t =y+"-"+at(m)+"-"+at(d)+"T"+at(hh)+":"+at(mm) +":"+at(ss)+"+08:00";
    draft.setTemplateTag("mytime", t);
    
  • createDraft

    template
    ---
    title: "[[line|1]]"
    date: [[mytime]]
    tags: ["[[tags]]"]
    categories: [""]
    draft: false
    ---
    [[body]]
    tags
    Blog
    folder
    inbox
    flagged
    false
    openInEditor
    true

Options

  • After Success Trash
    Notification Error
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.