jekyll-recker

my website's custom jekyll plugin



This is the jekyll plugin for my personal website.

Installation

Add jekyll-recker to the jekyll_plugins group of your Gemfile.

group :jekyll_plugins do
  gem 'jekyll-recker'
end

Add jekyll-recker to the list of plugins in jekyll’s _config.yml.

# _config.yaml
plugins:
  - jekyll-recker

Set the theme.

theme: jekyll-recker

Install and enjoy.

bundle install
bundle exec jekyll serve

Usage

Commands

slack

The slack command posts a slack message advertising the latest published jekyll blog post using a private incoming webhook.

Configure _config.yml

# _config.yml
recker:
  slack:
    MyTeam:
      channel: '#blogs'   # required!
      username: 'blogbot' # required!
      emoji: ':robot:'    # required!

Multiple teams are supported too!

# _config.yml
recker:
  slack:
    MyTeamA:
      channel: '#blogs'   # required!
      username: 'blogbot' # required!
      emoji: ':robot:'    # required!
    MyTeamB:
      channel: '#blogs'   # required!
      username: 'blogbot' # required!
      emoji: ':robot:'    # required!
    MyTeamC:
      channel: '#blogs'   # required!
      username: 'blogbot' # required!
      emoji: ':robot:'    # required!

Supply the private webhook through an environment variable.

export SLACK_MYTEAM_WEBHOOK="https://..."  # SLACK_ + <MyTeam.upcase> + _WEBHOOK

Alternatively, add the command with which to retrieve the webhook in _config.yml

# _config.yml
recker:
  slack:
    MyTeam:
      webhook_cmd: cat secrets/my-teams-secret-webhook.txt

Run bundle exec jekyll slack to let it rip!

assets/images/example-slack.png

Using the --dry flag, you can preview the message post without actually posting anything.

arecker@25732-arecker:~/src/blog$ be jekyll slack --dry
Configuration file: /Users/arecker/src/blog/_config.yml
jekyll-recker: reckerfamily: discovering webhook 
Configuration file: /Users/arecker/src/blog/_config.yml
jekyll-recker: reckerfamily: posting drag racing, windshield wipers, and alex's painting tips 
jekyll-recker: postign in dry mode, printing message 
jekyll-recker: BEGIN MESSAGE
Sunday, March 15 2020
drag racing, windshield wipers, and alex's painting tips
https://www.alexrecker.com/2020-03-15.html
END MESSAGE 

tweet

The tweet command tweets a link to the latest published jekyll blog post.

Ensure the following environment variables are set,.

export ACCESS_TOKEN_SECRET="..."
export ACCESS_TOKEN="..."
export CONSUMER_API_KEY="..."
export CONSUMER_API_SECRET="..."

Alternatively, configure which commands to run to fetch the secrets.

# _config.yml
recker:
  twitter:
    access_token_secret_cmd: cat secrets/access-token-secret
    access_token_cmd: cat secrets/access-token
    consumer_api_key_cmd: cat secrets/consumer-api-key
    consumer_api_secret_cmd: cat secrets/consumer-api-secret-key

Run bundle exec jekyll tweet to let it rip!

assets/images/example-tweet.png

Using the --dry flag, you can test your configuration without actually tweeting anything.

arecker@25732-arecker:~/src/blog$ be jekyll tweet --dry
jekyll-recker: discovering credentials 
Configuration file: /Users/arecker/src/blog/_config.yml
Configuration file: /Users/arecker/src/blog/_config.yml
jekyll-recker: tweeting drag racing, windshield wipers, and alex's painting tips 
jekyll-recker: tweeting in dry mode, printing message 
jekyll-recker: BEGIN TWEET
Sunday, March 15 2020
drag racing, windshield wipers, and alex's painting tips
https://www.alexrecker.com/2020-03-15.html
END TWEET 

Generators

stats

On build time, jekyll-recker calculates and stores the following stats in the site.data.stats object

Field Name Field Description
posts The total number of published posts.
words.total The total number of words from all published post.
words.average The average number of words for each published post.
days.days Current streak of daily, consecutive posts.
days.start First day of current streak.
days.end Last day of current streak.

Use these variables to render your own page of neat writing statistics!

<table>
  <tr>
    <th>Total Posts</th>
    <th>Total Words</th>
    <th>Average Words per Post</th>
    <th>Current Streak</th>
    <th>First day of current streak</th>
    <th>Last day of current streak</th>
  </tr>
  <tr>
    <td>{{ site.data.stats.posts }}</td>
    <td>{{ site.data.stats.words.total }}</td>
    <td>{{ site.data.stats.words.average }}</td>
    <td>{{ site.data.stats.days.days }}</td>
    <td>{{ site.data.stats.days.start }}</td>
    <td>{{ site.data.stats.days.end }}</td>
  </tr>
</table>