Skip to content

Commit

Permalink
Use variables instead of layout Front Matter
Browse files Browse the repository at this point in the history
  • Loading branch information
moisseev committed Apr 11, 2024
1 parent 1bc936d commit de1e0f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
13 changes: 5 additions & 8 deletions _includes/directory-tree.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
If the path ends with a slash, the directory itself will be excluded from the tree.
Default: The root directory.

Parameters that can be passed as include or Front Matter directory-tree hash:
Parameters that can be passed as include hash, Front Matter directory-tree hash or Liquid variables with directory-tree- prefix:

li The generated tree is a list item. Do not wrap an <ul> tag around it.

Expand All @@ -17,11 +17,8 @@
strong Wrap a <strong> tag around titles of the pages that have `strong: true` in the Front Matter.
Default: false.
{%- endcomment -%}
layout=<pre>{{ include | inspect }}</pre>
layout=<pre>{{ page | inspect }}</pre>
layout=<pre>{{ layout | inspect }}</pre>
{%- unless include.li or page.directory-tree.li or layout.directory-tree.li %}<ul>{%- endunless %}
{%- assign dir_class = include.dir_class | default: page.directory-tree.dir_class | default: layout.directory-tree.dir_class -%}
{%- unless include.li or page.directory-tree-li or directory-tree_li %}<ul>{%- endunless %}
{%- assign dir_class = include.dir_class | default: directory-tree-dir_class | default: page.directory-tree.dir_class -%}
{%- if dir_class -%}
{%- assign dir_li = '<li class="' | append: dir_class | append: '">' -%}
{%- else -%}
Expand Down Expand Up @@ -94,7 +91,7 @@
{%- assign prev_page_dir = pg.dir -%}
{%- endunless %}
{%- unless pg.name == "index.md" or pg.name == "index.html" -%}
{%- if pg.strong and include.strong or page.directory-tree.strong or layout.directory-tree.strong -%}
{%- if pg.strong and include.strong or page.directory-tree.strong or directory-tree-strong -%}
{%- assign strong = "<strong>" -%}
{%- assign strong_closing = "</strong>" -%}
{%- else -%}
Expand All @@ -113,4 +110,4 @@
</ul>
</li>
{%- endfor %}
{% unless include.li or page.directory-tree.li or layout.directory-tree.li -%}</ul>{%- endunless -%}
{% unless include.li or page.directory-tree.li or directory-tree-li -%}</ul>{%- endunless -%}
10 changes: 4 additions & 6 deletions _layouts/doc.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
---
directory-tree:
li: true
strong: true
dir_class: "r-docs-subnav list-group-item"
---
<!-- remove the white space after footer-->
{% include top.html %}

{%- assign directory-tree-li = true -%}
{%- assign directory-tree-strong = true -%}
{%- assign directory-tree-dir_class = "r-docs-subnav list-group-item" -%}

<style>
.r-docs-nav {
width: 300px;
Expand Down

0 comments on commit de1e0f3

Please sign in to comment.