Drafts Action Directory

Blog Template

Posted by @basepi, Last update 3 months ago

Basic blog template for Pelican including slug-ified title.

Install

Steps

  • script

    // See online documentation for examples
    // http://getdrafts.com/scripting
    // Slugify selected text.
    
    var p = Prompt.create();
    
    p.title = "New Blog Post";
    
    p.addTextField("blogTitle", "Title", "");
    
    p.addButton("OK");
    
    var didSelect = p.show();
    
    var blogTitle = p.fieldValues["blogTitle"];
    
    var slug = blogTitle.toLowerCase()
    				.replace(/["'=:!?@£#$%&\*\(\)\[\]_\+\|;~`<>,\.]+/g, '')
    				.replace(/ +/g,'-');
    
    draft.setTemplateTag("blogtitle", blogTitle);
    draft.setTemplateTag("blogslug", slug);
  • insertText

    template
    [[date]]-[[blogslug]]
    Title: [[blogtitle]]
    Date: [[date]]
    Category: Blog
    
    

Options

  • After Success Default
    Notification Info
    Log Level Info

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.