Skip to content

Commit

Permalink
Merge pull request #1 from harrison-broadbent/v1.1
Browse files Browse the repository at this point in the history
v1.1
  • Loading branch information
harrison-broadbent authored May 17, 2024
2 parents 5ba8da8 + dbb1233 commit 242f3ea
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 34 deletions.
14 changes: 8 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.8.1)
activesupport (7.0.8.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand All @@ -18,7 +18,7 @@ GEM
coffee-script-source (1.12.2)
concurrent-ruby (1.2.3)
contracts (0.16.1)
dotenv (3.1.0)
dotenv (3.1.2)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
Expand Down Expand Up @@ -94,11 +94,11 @@ GEM
middleman-core (>= 3.2)
rouge (~> 3.2)
mini_portile2 (2.8.6)
minitest (5.22.3)
nokogiri (1.16.4)
minitest (5.23.0)
nokogiri (1.16.5)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.4-arm64-darwin)
nokogiri (1.16.5-arm64-darwin)
racc (~> 1.4)
padrino-helpers (0.15.3)
i18n (>= 0.6.7, < 2)
Expand All @@ -115,11 +115,13 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.6)
rexml (3.2.8)
strscan (>= 3.0.9)
rouge (3.30.0)
sassc (2.4.0)
ffi (~> 1.9)
servolux (0.13.0)
strscan (3.1.0)
temple (0.10.3)
terser (1.2.2)
execjs (>= 0.3.0, < 3)
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Ruby Middleman Tailwind Starter Blog

[![Netlify Status](https://api.netlify.com/api/v1/badges/1d340bcd-8b88-47db-b12d-e83d2ac350ef/deploy-status)](https://app.netlify.com/sites/ruby-middleman-tailwind-starter-blog/deploys)

A Middleman blog template configured with TailwindCSS, markdown parsing, code highlighting, a sitemap.xml and more. It perfect for lightweight blogging or a personal website. Ruby knowledge is helpful, but not necessary.

## Features
Expand All @@ -15,7 +17,7 @@ A Middleman blog template configured with TailwindCSS, markdown parsing, code hi
- Perfect [100/100 PageSpeed score](https://pagespeed.web.dev/analysis/https-main--ruby-middleman-tailwind-starter-blog-netlify-app/o3pfqkngtp?form_factor=desktop) (near perfect for mobile)
- Github Action for image compression (see `compress_images.yml`).

Visit the [live template demo](https://main--ruby-middleman-tailwind-starter-blog.netlify.app/) for a preview of how it looks (although of course, you can customize it yourself).
Visit the [live template demo](https://ruby-middleman-tailwind-starter-blog.netlify.app/) for a preview of how it looks (although of course, you can customize it yourself).

I've used [Middleman](https://middlemanapp.com/) for years to build my personal website, and this template is a consolidation of everything I've learned.

Expand All @@ -26,8 +28,12 @@ Before you get started, make sure you've got Ruby installed. Currently, this tem
Clone this template, then install the required packages and start the server:

```sh
bundle # install packages
bin/dev # start dev server
# install Ruby packages & tailwindcss
bundle
npm install

# start dev server
bin/dev
```

## Deploying
Expand Down
18 changes: 11 additions & 7 deletions config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Template config
#
set :site_title, "Ruby+Middleman+Tailwind Starter Kit" # site title for <title> meta tag
set :site_url, "https://ruby-middleman-tailwind-starter-blog.netlify.app/" # for sitemap.xml.builder
set :site_title, "Ruby+Middleman+Tailwind Starter Kit" # site title for <title> meta tag
set :trailing_slash, false # turn site.com/home/ -> site.com/home

# Extensions
#
Expand All @@ -11,13 +13,13 @@
end

activate :blog do |blog|
blog.prefix = "blog" # directory prefix
blog.layout = "markdown_layout" # layout from source/layouts
blog.sources = "{title}.html" # filename glob
blog.permalink = "{title}.html" # format of the URLs middleman generates
blog.default_extension = ".md" # file extension
blog.publish_future_dated = true # by default only builds posts with future dates
blog.layout = "markdown_layout" # layout from source/layouts
blog.sources = "blog/{title}.html" # filename glob
blog.permalink = "{title}.html" # format of the URLs middleman generates
blog.default_extension = ".md" # file extension
blog.publish_future_dated = true # by default only builds posts with future dates
blog.new_article_template = File.expand_path("../source/template.erb", __FILE__)
# blog.prefix = "blog" # enable this to put your URLs in a sub-path like site.com/blog/article-name
end

# Middleman doesn't support per-filetype layouts.
Expand Down Expand Up @@ -49,6 +51,8 @@

#-------------#

# You can enable these if you want, but some static hosts already do this for you
#
# configure :build do
# activate :minify_css
# activate :minify_javascript, compressor: Terser.new
Expand Down
11 changes: 2 additions & 9 deletions source/blog.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@ description: A Middleman blog powered by the "middleman-blog" gem.

# Blog (the,)

Welcome to the blog. It's powered by the `middleman-blog` gem, alongside markdown files.
Welcome to the blog! It's powered by the `middleman-blog` gem and `.md` documents.

This is the index page, located at `source/blog.html.md.erb`. The blog extension itself is configured (within `config.rb`) to look inside `source/blog` for individual articles.

Here are some example articles —

<ul>
<% blog.articles.each do |article| %>
<li class="space-x-4">
<time>[<%= article.date.strftime('%b %e %Y') %>]</time>
<%= link_to article.title, article.url %>
</li>
<% end %>
</ul>
<%= partial "partials/article_list" %>
6 changes: 1 addition & 5 deletions source/blog/hello_blog.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,7 @@ Towards the start of `config.rb` you'll see this:

```ruby
activate :blog do |blog|
blog.prefix = "blog" # directory prefix
blog.sources = "{title}.html" # filename glob
blog.default_extension = ".md" # file extension
blog.layout = "markdown_layout" # layout from source/layouts
blog.permalink = "{title}.html" # format of the URLs middleman generates
...
end
```

Expand Down
2 changes: 1 addition & 1 deletion source/blog/other_template_features.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The `directory_indexes` extension is used for [pretty URLs](https://middlemanapp
I've included a sitemap at `source/sitemap.xml.builder`. This uses the `builder` gem to automatically generate a sitemap for your site:

```ruby
site_url = "https://main--ruby-middleman-tailwind-starter-blog.netlify.app"
site_url = config.site_url

xml.instruct!
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
Expand Down
2 changes: 0 additions & 2 deletions source/layouts/markdown_layout.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<%#
Wraps markdown_layout.erb with layout.erb
(this gets inserted into the "yield" in layout.erb)
If it's a blog article, displays "← Back | Date" above the title.
%>
<% wrap_layout :layout do %>
<div id="prose-content" class="prose">
Expand Down
8 changes: 8 additions & 0 deletions source/partials/_article_list.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ul>
<% blog.articles.each do |article| %>
<li class="space-x-4">
<time>[<%= article.date.strftime('%b %e %Y') %>]</time>
<%= link_to article.title, article.url %>
</li>
<% end %>
</ul>
2 changes: 1 addition & 1 deletion source/sitemap.xml.builder
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
site_url = "https://main--ruby-middleman-tailwind-starter-blog.netlify.app"
site_url = config.site_url

xml.instruct!
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
Expand Down

0 comments on commit 242f3ea

Please sign in to comment.