Action

Save Jekyll blog post

Posted by cdf1982, Last update almost 2 years ago

Save markdown file to _posts subfolder of Jekyll website.
Front matter title used as slugified file name; if title is empty, file name will be YYYY-mm-dd-post.md.
Commit and post not handled by the action; on iOS, you might want to manually trigger a Shortcut for Working Copy, while on macOS Gitwatch can be used to auto-commit and push.

Steps

  • script

    let lines = draft.content.split("\n");
    
    var titleLine = lines[2];
    var placeHolderNoSpace = titleLine.replace('title: ', 'title:');
    var removedPlaceholder = placeHolderNoSpace.replace('title:', '');
    var slugified = removedPlaceholder.replace(/ /g, '-');
    var lowercased = slugified.toLowerCase();
    
    var fileName = lowercased
    
    if (removedPlaceholder == '' || removedPlaceholder == ' ') {
    fileName = 'post';
    };
    
    draft.setTemplateTag("file", fileName);
  • file

    fileNameTemplate
    [[date|%Y-%m-%d]]-[[file]].md
    folderTemplate
    template
    [[draft]]
    local
    true
    writeType
    replace

Options

  • After Success Archive , Tags: blog
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.