Action

Blog Template

Posted by @basepi, Last update over 5 years ago

Basic blog template for Pelican including slug-ified title.

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
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.