From 19555c4700dcfa7fcfb09ad6cff8c63ac2705b61 Mon Sep 17 00:00:00 2001 From: fauno Date: Mon, 12 Jun 2017 15:09:44 -0500 Subject: [PATCH 1/2] Use slug in liquid templates I needed to use the slug on a layout and nothing was being printed until I realized the attribute isn't available in liquid :) --- lib/jekyll-archives/archive.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/jekyll-archives/archive.rb b/lib/jekyll-archives/archive.rb index b5f9492..9769647 100644 --- a/lib/jekyll-archives/archive.rb +++ b/lib/jekyll-archives/archive.rb @@ -15,6 +15,7 @@ class Archive < Jekyll::Page path url permalink + slug ).freeze # Initialize a new Archive page From c33e9db3dd5b502dd12c47eadb3ae8606578ff22 Mon Sep 17 00:00:00 2001 From: fauno Date: Tue, 21 Aug 2018 15:41:54 -0300 Subject: [PATCH 2/2] modes for slugify --- docs/configuration.md | 17 +++++++++++++++++ lib/jekyll-archives/archive.rb | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 645da4a..4a34f60 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -7,6 +7,7 @@ Archives configuration is done in the site's `_config.yml` file, under the `jeky jekyll-archives: enabled: [] layout: 'archive' + slug: nil permalinks: year: '/:year/' month: '/:year/:month/' @@ -80,6 +81,22 @@ layouts: --- +#### Slugs +| Key | Value type | Values | +|--------|------------|------------------------------------------------------------------------------------------------------| +| `slug` | String | A [mode for slugifying](https://www.rubydoc.info/github/jekyll/jekyll/Jekyll%2FUtils:slugify) titles | + +##### Description + +Specifies the mode to pass to `Jekyll::Utils.slugify` + +##### Sample values +```yml +slug: none|raw|default|pretty|ascii|latin +``` + +--- + #### Permalinks | Key | Value type | Values | |--------------|---------------------------|--------| diff --git a/lib/jekyll-archives/archive.rb b/lib/jekyll-archives/archive.rb index 9769647..b0645b6 100644 --- a/lib/jekyll-archives/archive.rb +++ b/lib/jekyll-archives/archive.rb @@ -34,7 +34,7 @@ def initialize(site, title, type, posts) # Generate slug if tag or category # (taken from jekyll/jekyll/features/support/env.rb) - @slug = Utils.slugify(title) if title.is_a? String + @slug = Utils.slugify(title, mode: @config.dig('slug')) if title.is_a? String # Use ".html" for file extension and url for path @ext = File.extname(relative_path)