fenton-jekyll-boilerplate 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 796e5046594287e61a04266f801d95941663ae0bd5e30949b3f60eeafbaaa6ee
4
- data.tar.gz: c948a2e05d83425390dc3f51cb284f2ecd1b274d4273d78d6d83c687ddc91373
3
+ metadata.gz: 11581973bf7e6ca7aef4afabb61f30fc637fe23a25ce4915237530770c28b6a1
4
+ data.tar.gz: cc5759349dfa4bd0af02200b01836181a119081470c11dc762ca8fbada6d0030
5
5
  SHA512:
6
- metadata.gz: e5be494b5120efc317a8cef43887dcbc196293ad4a5ef0f3405338f930482b3687599f7d0035055e90d4eb3002e5384b694356bb71956287b43207aeae465b89
7
- data.tar.gz: 9d65a265d19dc33f7f92d803b9513134231dea45201680617c05cba408e48ff92dc2bfaa327cde139c06018ff066b0856ca3f50ddd193b1cf0c6e288f25faad2
6
+ metadata.gz: bd76c0783fd77ba3574ff1d4d098f47922157570d9a87a09065ebac17b61d06ff5248275c134c618ffc0a404219e79baa38cd4d9e6f964af1354223f3001603c
7
+ data.tar.gz: e0aa8f8672db795f8cd2366fc5c56a446cc691c27136927234400e228ce67633d6f78815c1b235da7511fd0e212b969988ca96d5670cf07c3aede886bb535a31
@@ -1,3 +1,3 @@
1
- <script>
2
- // Analytics scripts
3
- </script>
1
+ {%- if site.analytics_script -%}
2
+ {{ site.analytics_script }}
3
+ {%- endif -%}
@@ -1,22 +1,19 @@
1
1
  {%- assign current_url = page.url | remove: 'index.html' %}
2
- <nav class="site-breadcrumbs" aria-label="{{ 'aria' | t: 'breadcrumbs' }}">
3
- <ol vocab="http://schema.org/" typeof="BreadcrumbList">
4
- {%- for crumb in breadcrumbs %}
5
- {%- if forloop.last %}
2
+ {%- assign aria_current = '' %}
3
+ <nav class="site-breadcrumbs" aria-label="{{ 'aria' | t: 'breadcrumbs' }}">
4
+ <ol vocab="http://schema.org/" typeof="BreadcrumbList">
5
+ {%- for crumb in breadcrumbs %}
6
+ {%- if forloop.last %}
7
+ {%- assign aria_current = ' aria-current="page"' %}
8
+ {%- else %}
9
+ {%- assign aria_current = '' %}
10
+ {%- endif %}
6
11
  <li property="itemListElement" typeof="ListItem">
7
- <a property="item" typeof="WebPage" href="{{ crumb.url | relative_url }}" aria-current="page">
12
+ <a property="item" typeof="WebPage" href="{{ crumb.url | relative_url }}"{{aria_current}}>
8
13
  <span property="name">{{ crumb.title }}</span>
9
14
  <meta property="position" content="{{ crumb.position }}" />
10
15
  </a>
11
16
  </li>
12
- {%- else %}
13
- <li property="itemListElement" typeof="ListItem">
14
- <a property="item" typeof="WebPage" href="{{ crumb.url | relative_url }}">
15
- <span property="name">{{ crumb.title }}</span>
16
- <meta property="position" content="{{ crumb.position }}" />
17
- </a>
18
- </li>
19
- {%- endif %}
20
- {%- endfor %}
21
- </ol>
17
+ {%- endfor %}
18
+ </ol>
22
19
  </nav>
@@ -1,52 +1,62 @@
1
+ {%- assign current_url = page.url | remove: 'index.html' %}
2
+ {%- assign previous = null %}
3
+ {%- assign page_num_regex = '/' | append: site.paginate_page | append: '[0-9]/' %}
4
+ {%- assign main_pages = site.pages | where: 'nav-level', '1' | sort: 'nav-order' %}
1
5
  <nav class="site-nav" id="site-nav" aria-label="{{ 'aria' | t: 'site_navigation' }}">
2
6
  <h2 class="site-nav-title">{{ 'navigation' | t: 'title' }}</h2>
3
7
  <ul>
4
- {%- assign current_url = page.url | remove: 'index.html' %}
5
- {%- assign previous = null %}
6
- {%- assign regex = '/' | append: site.paginate_page | append: '[0-9]/' %}
7
- {%- assign main_pages = site.pages | where: 'nav-level', '1' | sort: 'nav-order' -%}
8
- {% for item in main_pages %}
8
+ {%- for item in main_pages %}
9
9
  {%- assign current = item.nav-title | default: item.title %}
10
- {%- if (current != previous) %}
11
- {%- assign previous = item.nav-title | default: item.title %}
12
10
 
13
- {%- assign parent_perma = item.permalink %}
14
- {%- assign parent_perma_size = parent_perma | size %}
15
- {%- assign sub_pages = '' | split: '' %}
11
+ {%- comment %}Paging can introduce duplicates{% endcomment %}
12
+ {%- if current == previous %}
13
+ {%- continue %}
14
+ {%- endif %}
16
15
 
17
- {%- for p in site.pages %}
18
- {%- assign child_perma = p.permalink %}
19
- {%- assign child_perma_truncated = child_perma | truncate: parent_perma_size, '' %}
16
+ {%- comment %}Hierarchy and selected items are determined based on URL{% endcomment %}
17
+ {%- assign previous = item.nav-title | default: item.title %}
18
+ {%- assign parent_perma = item.permalink %}
19
+ {%- assign parent_perma_size = parent_perma | size %}
20
+ {%- assign sub_pages = '' | split: '' %}
21
+ {%- assign current_url_truncated = current_url | truncate: parent_perma_size, '' %}
22
+
23
+ {%- comment %}Find matching child pages by path{% endcomment %}
24
+ {%- for potential_sub_page in site.pages %}
25
+ {%- assign child_perma = potential_sub_page.permalink %}
26
+ {%- assign child_perma_truncated = child_perma | truncate: parent_perma_size, '' %}
20
27
 
21
- {%- if p.nav-level != 0 and parent_perma != '/' and child_perma_truncated == parent_perma and child_perma != parent_perma %}
22
- {%- assign sub_pages = sub_pages | push: p %}
23
- {%- endif %}
24
- {%- endfor %}
28
+ {%- if potential_sub_page.nav-level != 0 and parent_perma != '/' and child_perma_truncated == parent_perma and child_perma != parent_perma %}
29
+ {%- assign sub_pages = sub_pages | push: potential_sub_page %}
30
+ {%- endif %}
31
+ {%- endfor %}
25
32
 
26
33
  <li{%- if sub_pages.size > 0 %} class="has-children"{% endif %}>
27
- {%- assign item_url = item.url | regex_replace: regex,'/' | prepend: site.baseurl %}
28
- {%- if sub_pages.size > 0 %}
29
- <details class="sub-nav">
34
+ {%- assign item_url = item.url | regex_replace: page_num_regex,'/' | prepend: site.baseurl %}
35
+
36
+ {%- comment %}Details added if child pages exist{% endcomment %}
37
+ {%- if sub_pages.size > 0 %}
38
+ <details class="sub-nav"{% if current_url_truncated == parent_perma %} open="open"{% endif %}>
30
39
  <summary><span>{{ item.nav-section | default: item.nav-title | default: item.title }}</span></summary>
31
- {%- else %}
40
+ {%- else %}
32
41
  <a href="{{ item_url }}"{% if item_url == current_url) %} class="current-item" aria-current="page"{% endif %}>{{ item.nav-title | default: item.title }}</a>
33
- {%- endif -%}
34
- {% if sub_pages.size > 0 %}
42
+ {%- endif -%}
43
+
44
+ {%- comment %}Child pages list, parent injected as first item{% endcomment %}
45
+ {%- assign sub_pages_sorted = sub_pages | sort: 'nav-order' %}
46
+ {% if sub_pages.size > 0 %}
35
47
  <ul>
36
48
  <li>
37
49
  <a href="{{ item_url }}"{% if item_url == current_url) %} class="current-item" aria-current="page"{% endif %}>{{ item.nav-title | default: item.title }}</a>
38
50
  </li>
39
- {%- assign sub_pages_sorted = sub_pages | sort: 'nav-order' %}
40
- {%- for child in sub_pages_sorted %}
51
+ {%- for child in sub_pages_sorted %}
41
52
  <li>
42
53
  <a href="{{ child.url | prepend: site.baseurl }}"{% if child.url == current_url) %} class="current-item" aria-current="page"{% endif %}>{{ child.nav-title | default: child.title }}</a>
43
54
  </li>
44
- {%- endfor %}
55
+ {%- endfor %}
45
56
  </ul>
46
57
  </details>
47
- {%- endif %}
58
+ {%- endif %}
48
59
  </li>
49
- {%- endif %}
50
60
  {%- endfor %}
51
61
  </ul>
52
62
  </nav>
data/assets/js/main.js CHANGED
@@ -1,6 +1,5 @@
1
1
  // @ts-check
2
2
 
3
- import { setNavigationTree } from './modules/nav-expand.js';
4
3
  import { setClickableBlocks } from './modules/click-blocks.js';
5
4
  import { addResizedEvent } from './modules/resizing.js';
6
5
  import { addStickyNavigation } from './modules/nav-sticky.js';
@@ -8,11 +7,9 @@ import { addMobileNavigation } from './modules/nav-mobile.js';
8
7
  import { addIntersectionObserver } from './modules/animation.js';
9
8
  import { qsa } from './modules/query.js';
10
9
 
11
- setNavigationTree('details.sub-nav');
12
- setClickableBlocks();
13
-
14
10
  const resizedEventName = addResizedEvent();
15
11
 
12
+ setClickableBlocks();
16
13
  addStickyNavigation('.site-header', '.site-nav', '.site-nav > ul', resizedEventName);
17
14
  addMobileNavigation('.navigation-icon', '.site-nav', resizedEventName);
18
15
  addIntersectionObserver('.post-list .list-item, main img, main .note, main blockquote');
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fenton-jekyll-boilerplate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Fenton
@@ -75,7 +75,6 @@ files:
75
75
  - assets/js/modules/click-blocks.js
76
76
  - assets/js/modules/events.js
77
77
  - assets/js/modules/focus.js
78
- - assets/js/modules/nav-expand.js
79
78
  - assets/js/modules/nav-mobile.js
80
79
  - assets/js/modules/nav-sticky.js
81
80
  - assets/js/modules/query.js
@@ -1,28 +0,0 @@
1
- // @ts-check
2
-
3
- import { qs, qsa } from './query.js';
4
-
5
- /**
6
- * Sets the navigation based on the current page
7
- *
8
- * Example: You have a navigation tree with an "About" page with several child items.
9
- * When the user is on the "About" page, or any child pages, the navigation should
10
- * be automatically expanded so the user can orient themselves within the site.
11
- *
12
- * @param {string} className
13
- */
14
- function setNavigationTree(className) {
15
- const site = document.location.origin;
16
- const location = document.location.pathname;
17
-
18
- qsa(className).forEach((summary) => {
19
- const anchorElement = /** @type {HTMLAnchorElement} */(qs('a', summary));
20
- const address = anchorElement.href.replace(site, '');
21
-
22
- if (location.startsWith(address)){
23
- summary.setAttribute('open', 'open');
24
- }
25
- });
26
- }
27
-
28
- export { setNavigationTree };