mirror of
https://github.com/forestryio/jekyll-menus.git
synced 2025-07-04 00:01:22 -04:00
Compare commits
48 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
288acfacfa | ||
|
21607b627b | ||
|
41b23d6568 | ||
|
6c8b53eeb0 | ||
|
2ba953f41f | ||
|
ebafa6207a | ||
|
4eeffa3021 | ||
|
34fd696fd6 | ||
|
1f020335bf | ||
|
e6f021a666 | ||
|
4bfea59378 | ||
|
c157ba39a4 | ||
|
3e8eb755e0 | ||
|
f69126e4bb | ||
|
f33b6afd7c | ||
|
51ec3d866c | ||
|
fbcc9b9a48 | ||
|
94286c3317 | ||
|
4979b35fc4 | ||
|
d170b60841 | ||
|
c94954c525 | ||
|
f4f7649ccf | ||
|
6145dc74e6 | ||
|
adaffc454b | ||
|
b699363013 | ||
|
739ba03295 | ||
|
3e7d01c447 | ||
|
63977db5c1 | ||
|
40f0652f39 | ||
|
6009087b44 | ||
|
05fcf28891 | ||
|
02205eeb4a | ||
|
8ad3c3fe07 | ||
|
22d873d95e | ||
|
9af8cc15e2 | ||
|
0db6d7112c | ||
|
0f08a5e7ca | ||
|
c81b75c62b | ||
|
4cf7b543fd | ||
|
54c6c337b4 | ||
|
ae18d0e77b | ||
|
a737321189 | ||
|
a1f3d1d5ec | ||
|
d4cd98d253 | ||
|
4d9ea00fd8 | ||
|
13a7d18f69 | ||
|
7a0147163a | ||
|
adf2d56f4a |
@ -12,14 +12,14 @@ Gem::Specification.new do |spec|
|
|||||||
spec.description = "Menus (site navigation) for your Jekyll website"
|
spec.description = "Menus (site navigation) for your Jekyll website"
|
||||||
spec.summary = "Menus (navigation) for your very own Jekyll website."
|
spec.summary = "Menus (navigation) for your very own Jekyll website."
|
||||||
spec.files = %W(Gemfile) + Dir["lib/**/*"]
|
spec.files = %W(Gemfile) + Dir["lib/**/*"]
|
||||||
spec.required_ruby_version = ">= 2.1.0"
|
spec.required_ruby_version = ">= 2.4.0"
|
||||||
spec.email = ["jordon@envygeeks.io"]
|
spec.email = ["jordon@envygeeks.io"]
|
||||||
spec.require_paths = ["lib"]
|
spec.require_paths = ["lib"]
|
||||||
spec.name = "jekyll-menus"
|
spec.name = "jekyll-menus"
|
||||||
spec.has_rdoc = false
|
spec.has_rdoc = false
|
||||||
spec.license = "MIT"
|
spec.license = "MIT"
|
||||||
|
|
||||||
spec.add_runtime_dependency("jekyll", "~> 3.1")
|
spec.add_runtime_dependency("jekyll", ">= 3.6", "< 5.0" )
|
||||||
spec.add_development_dependency(
|
spec.add_development_dependency(
|
||||||
"rspec", ">= 3", "< 4"
|
"rspec", ">= 3", "< 4"
|
||||||
)
|
)
|
||||||
|
250
README.md
250
README.md
@ -1,92 +1,220 @@
|
|||||||
# Jekyll Menus
|
# Jekyll Menus
|
||||||
|
|
||||||
Complex menus for Jekyll.
|
A robust, simple-to-use menu plugin for Jekyll that allows for infinitely nested menus.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
To install and use Jekyll Menus, you should have Ruby, and either [RubyGems](https://jekyllrb.com/docs/installation/#install-with-rubygems), or we recommend using [Bundler](https://bundler.io/#getting-started). Bundler is what Jekyll will prefer you to use by default if you `jekyll new`.
|
||||||
|
|
||||||
|
### Using Bundler
|
||||||
|
|
||||||
|
You can add our gem to the `jekyll_plugins` group in your `Gemfile`:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
group :jekyll_plugins do
|
||||||
|
gem "jekyll-menus"
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
And then install from shell.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
bundle install
|
||||||
|
# --path vendor/bundle
|
||||||
|
```
|
||||||
|
|
||||||
|
***If you are using Jekyll Docker, you do not need to perform this step, Jekyll Docker will perform it on your behalf when you launch the image, you only need to perform this step if you are working directly on your system.***
|
||||||
|
|
||||||
|
### Using RubyGems
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo gem install jekyll-menus
|
||||||
|
sudo gem update jekyll-menus
|
||||||
|
```
|
||||||
|
|
||||||
|
Once installed, add the Gem to your `_config.yml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
plugins:
|
||||||
|
- jekyll-menus
|
||||||
|
```
|
||||||
|
|
||||||
|
***Note in earlier versions of Jekyll, `plugins` should instead be `gems`***
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
You can create `_data/menu.yml`, `_data/menus.yml`, or both, or add menu items
|
Jekyll Menus allows you to create menus by attaching posts and pages to menus through their front matter, or by defining custom menu items via `_data/menus.yml`.
|
||||||
via your front-matter. Both are merged into the same menus so you can even
|
|
||||||
split off menus between the two, so that you can have menus that have
|
|
||||||
internal and external links! Just make sure the identifiers match.
|
|
||||||
|
|
||||||
### Front-Matter Examples
|
Jekyll Menus adds a new option to the site variable called `site.menus`, which can be looped over just like pages, posts, and other content:
|
||||||
#### String Key Menu Item
|
|
||||||
|
|
||||||
```yml
|
```liquid
|
||||||
|
<ul>
|
||||||
|
{% for item in site.menus.header %}
|
||||||
|
<li class="menu-item-{{ loop.index }}">
|
||||||
|
<a href="{{ item.url }}" title="Go to {{ item.title }}">{{ item.title }}</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Menus via Front Matter
|
||||||
|
|
||||||
|
The easiest way to use Jekyll Menus is to start building menus using your existing posts and pages. This can be done by adding a `menus` variable to your front matter:
|
||||||
|
|
||||||
|
```markdown
|
||||||
---
|
---
|
||||||
menus: main
|
title: Homepage
|
||||||
|
menus: header
|
||||||
---
|
---
|
||||||
```
|
```
|
||||||
|
|
||||||
The above configuration will infer all data (url, title, identifier, weight)
|
This will create the `header` menu with a single item, the homepage. The `url`, `title`, and `identifier` for the homepage menu item will be automatically generated from the pages title, file path, and permalink.
|
||||||
from your page data, the default weight is "-1" and the identifier is made from
|
|
||||||
the pages slug, which Jekyll itself generates. It will also place the page
|
|
||||||
on the "main" menu on your behalf after inferring said data.
|
|
||||||
|
|
||||||
#### Array of String Key Menu Items
|
You can optionally set any of the available [menu item variables](#menu-items) yourself to customize the appearance and functionality of your menus. For example, to set a custom title and weight:
|
||||||
|
|
||||||
```yml
|
```markdown
|
||||||
---
|
---
|
||||||
|
title: Homepage
|
||||||
menus:
|
menus:
|
||||||
- header
|
header:
|
||||||
- footer
|
title: Home
|
||||||
|
weight: 1
|
||||||
---
|
---
|
||||||
```
|
```
|
||||||
|
|
||||||
The above configuration will infer all data (url, title, identifier, weight)
|
## Custom Menu Items via `_data/menus.yml`
|
||||||
from your page data, the default weight is "-1" and the identifier is made from
|
|
||||||
the pages slug, which Jekyll itself generates. It will also place the page
|
|
||||||
on the "header", and "footer" menus after inferring said data.
|
|
||||||
|
|
||||||
#### Hash with Key as Identifier
|
The other option for configuring menus is creating menus using `_data/menus.yml`. In this scenario, you can add custom menu items to external content, or site content that isn’t handled by Jekyll.
|
||||||
|
|
||||||
```yml
|
In this file, you provide the menu key and an array of custom menu items. Custom menu items in the data file must have `url`, `title`, and `identifier` variable:
|
||||||
|
|
||||||
|
```markdown
|
||||||
---
|
---
|
||||||
|
header:
|
||||||
|
- url: /api
|
||||||
|
title: API Documentation
|
||||||
|
identifier: api
|
||||||
|
---
|
||||||
|
```
|
||||||
|
|
||||||
|
## Sub-menus
|
||||||
|
|
||||||
|
Jekyll Menus supports infinitely nested menu items using the `identifier` variable. Any menu item can be used as a parent menu by using its identifier as the menu.
|
||||||
|
|
||||||
|
For example, in `_data/menus.yml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
header:
|
||||||
|
- url: /api
|
||||||
|
title: API Documentation
|
||||||
|
identifier: api
|
||||||
|
```
|
||||||
|
|
||||||
|
In a content file called `/api-support.html`:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
---
|
||||||
|
title: Get API Support
|
||||||
|
menus: api
|
||||||
|
---
|
||||||
|
```
|
||||||
|
|
||||||
|
Which can then be used in your templates by looping over the menu item’s `children` variable:
|
||||||
|
|
||||||
|
```liquid
|
||||||
|
<ul>
|
||||||
|
{% for item in site.menus.header %}
|
||||||
|
<li class="menu-item-{{ loop.index }}">
|
||||||
|
<a href="{{ item.url }}" title="Go to {{ item.title }}">{{ item.title }}</a>
|
||||||
|
{% if item.children %}
|
||||||
|
<ul class="sub-menu">
|
||||||
|
{% for item in item.children %}
|
||||||
|
<li class="menu-item-{{ loop.index }}">
|
||||||
|
<a href="{{ item.url }}" title="Go to {{ item.title }}">{{ item.title }}</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also do this [recursively using a re-usable include](#recursive-menus), allowing for easily managed infinitely nested menus.
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
|
||||||
|
Jekyll Menus has the following variables:
|
||||||
|
|
||||||
|
### Menus
|
||||||
|
|
||||||
|
| Variable | Description |
|
||||||
|
|---|---|
|
||||||
|
| menu.menu | Returns a JSON object with all of the menu’s items. |
|
||||||
|
| menu.identifier | The unique identifier for the current menu, generated from the menu key. Allows for nested menu items. |
|
||||||
|
| menu.parent | The parent menu. Resolves to the site.menus object for top-level menus. |
|
||||||
|
|
||||||
|
### Menu Items
|
||||||
|
|
||||||
|
| Variable | Description |
|
||||||
|
|---|---|
|
||||||
|
| item.title | The display title of the menu item. Automatically set as the post or page title if no value is provided in front matter. |
|
||||||
|
| item.url | The URL the menu item links to. Automatically set to the post or page URL if no value is provided in front matter. |
|
||||||
|
| item.weight | Handles the order of menu items through a weighted system, starting with 1 being first. |
|
||||||
|
| item.identifier | The unique identifier for the current menu item. Allows for nested menu items. Automatically resolved to the page’s file path and filename if not provided in front matter. |
|
||||||
|
| item.parent | The parent menu. |
|
||||||
|
| item.children | An array of any child menu items. Used to create sub-menus. |
|
||||||
|
|
||||||
|
## Custom Variables
|
||||||
|
|
||||||
|
Menu items also support custom variables, which you add to each menu item in the front matter or data file.
|
||||||
|
|
||||||
|
For example, adding a `pre` or `post` variable to add text or HTML to your menu items:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
---
|
||||||
|
title: Homepage
|
||||||
menus:
|
menus:
|
||||||
main:
|
header:
|
||||||
url: "/custom-url"
|
pre: <i class="icon-home"></i>
|
||||||
|
post: " · "
|
||||||
---
|
---
|
||||||
```
|
```
|
||||||
|
|
||||||
The above will place a menu on "main" and override the URL for you inferring
|
## Recursive Menus
|
||||||
the rest of the data on your behalf. You can add multiple keys with hashes
|
|
||||||
if you wish to place the item on multiple menus, and you can override as much
|
|
||||||
as you wish at that time. ***Data is not inferred between items, so if you
|
|
||||||
override in one you must override in all, or the default values will be
|
|
||||||
used.***
|
|
||||||
|
|
||||||
### `_data/menu.yml`, `_data/menus.yml`
|
If you’re looking to build an infinitely nested menu (or a menu that is nested more than once up to a limit) then you should set up a reusable menu include that will handle this for you.
|
||||||
|
|
||||||
***All data within menu(s).yml must provide url, title, identifier, and
|
In `_includes/menu.html` :
|
||||||
weight (actually weight is optional)***
|
|
||||||
|
|
||||||
Menu items within data files must follow a key array format, or a key hash
|
```liquid
|
||||||
format, we do not accept string formats because we do not infer data, it's
|
{% if menu %}
|
||||||
impossible to infer such data efficiently and the data files are mostly built
|
<ul>
|
||||||
for you to add external links or links to other parts of your site that are
|
{% for item in menu %}
|
||||||
considered sub-domains. Examples:
|
<li class="menu-item-{{ loop.index }}">
|
||||||
|
<a href="{{ item.url }}" title="Go to {{ item.title }}">{{ item.title }}</a>
|
||||||
```yml
|
{% if item.children %}
|
||||||
main:
|
{% assign menu = item.children %}
|
||||||
- title: Title
|
{% include menu.html %}
|
||||||
identifier: title
|
{% endif %}
|
||||||
url: url
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
```
|
```
|
||||||
|
|
||||||
```yml
|
In `_layouts/default.html` (or any layout file):
|
||||||
main:
|
|
||||||
title: Title
|
```liquid
|
||||||
identifier: title
|
<html>
|
||||||
url: url
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav>
|
||||||
|
{% assign menu = site.menus.header %}
|
||||||
|
{% include menus.html %}
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
{{ content }}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
***It should be noted that _data/menu.yml and _data/menus.yml are both read
|
|
||||||
and merged, so you can have one, or both... we won't judge you if you happen
|
|
||||||
to use both of these files at once, it's your choice!***
|
|
||||||
|
|
||||||
### Custom Menu Data
|
|
||||||
|
|
||||||
You can add any amount of custom data you wish to an item, we do not remove
|
|
||||||
data, and we do not block it, we will pass any data you wish to put into the
|
|
||||||
into the menu item. It is up to you what data you put there, we only check
|
|
||||||
that our own keys exist, and if they don't then we fail in certain scenarios.
|
|
||||||
|
@ -13,23 +13,34 @@ module Jekyll
|
|||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
def to_liquid_drop
|
def menus
|
||||||
Drops::All.new(Utils.deep_merge(
|
Utils.deep_merge(_data_menus, Utils.deep_merge(
|
||||||
_config_menus, _page_menus
|
_page_menus, _collection_menus
|
||||||
))
|
))
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
def _config_menus
|
def to_liquid_drop
|
||||||
mns = [@site.data["menu"], @site.data["menus"]]
|
Drops::All.new(
|
||||||
out = {}; mns.compact.each do |menus|
|
menus
|
||||||
menus.each do |key, menu|
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
|
def _data_menus
|
||||||
|
out = {}
|
||||||
|
|
||||||
|
if @site.data["menus"] && @site.data["menus"].is_a?(Hash)
|
||||||
|
then @site.data["menus"].each do |key, menu|
|
||||||
if menu.is_a?(Hash) || menu.is_a?(Array)
|
if menu.is_a?(Hash) || menu.is_a?(Array)
|
||||||
(menu = [menu].flatten).each do |item|
|
(menu = [menu].flatten).each do |item|
|
||||||
_validate_config_menu_item(
|
_validate_config_menu_item(
|
||||||
item
|
item
|
||||||
)
|
)
|
||||||
|
|
||||||
|
item["_frontmatter"] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -38,9 +49,10 @@ module Jekyll
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
out = Utils.deep_merge(out, {
|
merge = { key => menu }
|
||||||
key => menu
|
out = Utils.deep_merge(
|
||||||
})
|
out, merge
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -54,70 +66,93 @@ module Jekyll
|
|||||||
|
|
||||||
@site.pages.select { |p| p.data.keys.grep(/menus?/).size > 0 }.each_with_object({}) do |page|
|
@site.pages.select { |p| p.data.keys.grep(/menus?/).size > 0 }.each_with_object({}) do |page|
|
||||||
[page.data["menus"], page.data["menu"]].flatten.compact.map do |menu|
|
[page.data["menus"], page.data["menu"]].flatten.compact.map do |menu|
|
||||||
|
out = _front_matter_menu(menu, page, out)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
out
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
|
def _collection_menus
|
||||||
|
out = {}
|
||||||
|
|
||||||
|
@site.collections.each do |collection, pages|
|
||||||
|
pages.docs.select { |p| p.data.keys.grep(/menus?/).size > 0 }.each_with_object({}) do |page|
|
||||||
|
[page.data["menus"], page.data["menu"]].flatten.compact.map do |menu|
|
||||||
|
out = _front_matter_menu(menu, page, out)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
out
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
|
def _front_matter_menu(menu, page, out={})
|
||||||
|
# --
|
||||||
|
# menu: key
|
||||||
|
# menu:
|
||||||
|
# - key1
|
||||||
|
# - key2
|
||||||
|
# --
|
||||||
|
|
||||||
|
if menu.is_a?(Array) || menu.is_a?(String)
|
||||||
|
_simple_front_matter_menu(menu, **{
|
||||||
|
:mergeable => out, :page => page
|
||||||
|
})
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
|
elsif menu.is_a?(Hash)
|
||||||
|
menu.each do |key, item|
|
||||||
|
out[key] ||= []
|
||||||
|
|
||||||
# --
|
# --
|
||||||
# menu: key
|
|
||||||
# menu:
|
# menu:
|
||||||
# - key1
|
# key: identifier
|
||||||
# - key2
|
|
||||||
# --
|
# --
|
||||||
|
|
||||||
if menu.is_a?(Array) || menu.is_a?(String)
|
if item.is_a?(String)
|
||||||
_simple_front_matter_menu(menu, {
|
out[key] << _fill_front_matter_menu({ "identifier" => item }, **{
|
||||||
:mergeable => out, :page => page
|
:page => page
|
||||||
})
|
})
|
||||||
|
|
||||||
#
|
# --
|
||||||
|
# menu:
|
||||||
|
# key:
|
||||||
|
# url: /url
|
||||||
|
# --
|
||||||
|
|
||||||
elsif menu.is_a?(Hash)
|
elsif item.is_a?(Hash)
|
||||||
menu.each do |key, item|
|
out[key] << _fill_front_matter_menu(item, **{
|
||||||
out[key] ||= []
|
:page => page
|
||||||
|
})
|
||||||
# --
|
|
||||||
# menu:
|
|
||||||
# key: identifier
|
|
||||||
# --
|
|
||||||
|
|
||||||
if item.is_a?(String)
|
|
||||||
out[key] << _fill_front_matter_menu({ "identifier" => item }, {
|
|
||||||
:page => page
|
|
||||||
})
|
|
||||||
|
|
||||||
# --
|
|
||||||
# menu:
|
|
||||||
# key:
|
|
||||||
# url: /url
|
|
||||||
# --
|
|
||||||
|
|
||||||
elsif item.is_a?(Hash)
|
|
||||||
out[key] << _fill_front_matter_menu(item, {
|
|
||||||
:page => page
|
|
||||||
})
|
|
||||||
|
|
||||||
# --
|
|
||||||
# menu:
|
|
||||||
# key:
|
|
||||||
# - url: /url
|
|
||||||
# --
|
|
||||||
|
|
||||||
else
|
|
||||||
_throw_invalid_menu_entry(
|
|
||||||
item
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# --
|
# --
|
||||||
# menu:
|
# menu:
|
||||||
# key: 3
|
# key:
|
||||||
|
# - url: /url
|
||||||
# --
|
# --
|
||||||
|
|
||||||
else
|
else
|
||||||
_throw_invalid_menu_entry(
|
_throw_invalid_menu_entry(
|
||||||
menu
|
item
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# --
|
||||||
|
# menu:
|
||||||
|
# key: 3
|
||||||
|
# --
|
||||||
|
|
||||||
|
else
|
||||||
|
_throw_invalid_menu_entry(
|
||||||
|
menu
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
out
|
out
|
||||||
@ -143,7 +178,7 @@ module Jekyll
|
|||||||
|
|
||||||
else
|
else
|
||||||
mergeable[menu] ||= []
|
mergeable[menu] ||= []
|
||||||
mergeable[menu] << _fill_front_matter_menu(nil, {
|
mergeable[menu] << _fill_front_matter_menu(nil, **{
|
||||||
:page => page
|
:page => page
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -157,14 +192,26 @@ module Jekyll
|
|||||||
val ||= {}
|
val ||= {}
|
||||||
|
|
||||||
val["url"] ||= page.url
|
val["url"] ||= page.url
|
||||||
|
val["identifier"] ||= slug(page)
|
||||||
|
val["_frontmatter"] = page.relative_path # `page.url` can be changed with permalink frontmatter
|
||||||
val["title"] ||= page.data["title"]
|
val["title"] ||= page.data["title"]
|
||||||
val["identifier"] ||= File.basename(page.name, page.ext)
|
|
||||||
val["weight"] ||= -1
|
val["weight"] ||= -1
|
||||||
val
|
val
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
|
private
|
||||||
|
def slug(page)
|
||||||
|
ext = page.data["ext"] || page.ext
|
||||||
|
out = File.join(File.dirname(page.path), File.basename(page.path, ext))
|
||||||
|
out.tr("^a-z0-9-_\\/", "").gsub(/\/|\-+/, "_").gsub(
|
||||||
|
/^_+/, ""
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
private
|
private
|
||||||
def _validate_config_menu_item(item)
|
def _validate_config_menu_item(item)
|
||||||
if !item.is_a?(Hash) || !item.values_at("url", "title", "identifier").compact.size == 3
|
if !item.is_a?(Hash) || !item.values_at("url", "title", "identifier").compact.size == 3
|
||||||
|
@ -56,16 +56,15 @@ module Jekyll
|
|||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
def method_missing(method, *args)
|
def before_method(method)
|
||||||
if args.size == 0 && @item.has_key?(method.to_s)
|
if @item.has_key?(method.to_s)
|
||||||
return @item[
|
return @item[
|
||||||
method.to_s
|
method.to_s
|
||||||
]
|
]
|
||||||
|
|
||||||
else
|
|
||||||
super
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias_method :liquid_method_missing, :before_method
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,6 +4,6 @@
|
|||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
class Menus
|
class Menus
|
||||||
VERSION = "0.0.2"
|
VERSION = "0.6.1"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
9
spec/fixture/hello/array-of-strings.md
Normal file
9
spec/fixture/hello/array-of-strings.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
title: Array of Strings
|
||||||
|
layout: default
|
||||||
|
menu:
|
||||||
|
- header
|
||||||
|
- footer
|
||||||
|
---
|
||||||
|
|
||||||
|
A Page
|
Loading…
x
Reference in New Issue
Block a user