willamette 0.8.0 → 0.9.0
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 +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -1
- data/automations/components.automation.rb +28 -11
- data/layouts/willamette/default.erb +0 -2
- data/lib/willamette/locales/en.yml +3 -0
- data/lib/willamette/strategies/base.rb +41 -0
- data/lib/willamette/strategies/link.rb +5 -3
- data/lib/willamette/strategies/navbar.rb +43 -0
- data/lib/willamette/strategies/sidebar.rb +27 -55
- data/lib/willamette/version.rb +1 -1
- data/lib/willamette.rb +2 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a4b853f52bf79b6b1653d57cafb45bbc7dc904f8de77e885fddf57de1724649a
|
|
4
|
+
data.tar.gz: 4b6f1bd188e86211babaa5f3ef67ada6f533e3465089e6d3ef42c5cf39a3088d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 88291ce695014b0647393b6c00119beab4b30b9ddd9b3afe5798b34d64d27fb04ccce61671fcd36de863213bc252d719dfd587409c486b6ff919cc516a72102e
|
|
7
|
+
data.tar.gz: a549b26f00fc725f59b507d73bba533ee1b791b1242b4709249b6f7d402baa71f19e2890ecd7e36db60c514f84a79146633eb070426159641e1e0ab4918b3bd8
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
willamette (0.
|
|
4
|
+
willamette (0.9.0)
|
|
5
5
|
bridgetown (>= 2.1, < 3.0)
|
|
6
6
|
nokolexbor (>= 0.6)
|
|
7
7
|
|
|
@@ -241,6 +241,7 @@ DEPENDENCIES
|
|
|
241
241
|
minitest
|
|
242
242
|
minitest-profile
|
|
243
243
|
minitest-reporters
|
|
244
|
+
nokolexbor
|
|
244
245
|
rake (>= 13.0)
|
|
245
246
|
rubocop-bridgetown (~> 0.7)
|
|
246
247
|
solargraph (~> 0.58.2)
|
|
@@ -5,9 +5,25 @@ remove_file "src/_components/shared/navbar.rb"
|
|
|
5
5
|
create_file "src/_components/shared.rb" do <<~RUBY
|
|
6
6
|
module Shared
|
|
7
7
|
class Navbar < Bridgetown::Component
|
|
8
|
-
attr_reader :metadata, :resource
|
|
8
|
+
attr_reader :metadata, :resource, :strategy
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
# @param metadata [HashWithDotAccess::Hash]
|
|
11
|
+
# @param resource [Bridgetown::Resource::Base]
|
|
12
|
+
def initialize(metadata:, resource:)
|
|
13
|
+
@metadata, @resource = metadata, resource
|
|
14
|
+
|
|
15
|
+
@strategy = Willamette.navbar(
|
|
16
|
+
self,
|
|
17
|
+
logo: "/willamette/bridgetown-avatar.svg",
|
|
18
|
+
logo_alt: "Website Logo",
|
|
19
|
+
site_title: metadata.title,
|
|
20
|
+
nav_links: [
|
|
21
|
+
Willamette.link(title: t("nav.blog"), url: "/blog"),
|
|
22
|
+
Willamette.link(title: t("nav.about"), url: "/about"),
|
|
23
|
+
Willamette.link(icon: "mastodon", icon_family: "brands", icon_label: "Mastodon", title: nil, url: "https://mastodon.social"),
|
|
24
|
+
]
|
|
25
|
+
)
|
|
26
|
+
end
|
|
11
27
|
end
|
|
12
28
|
|
|
13
29
|
class Sidebar < Bridgetown::Component
|
|
@@ -50,18 +66,19 @@ create_file "src/_components/shared/navbar.erb" do <<~HTML
|
|
|
50
66
|
<% end %>
|
|
51
67
|
|
|
52
68
|
<a slot="logo" href="/">
|
|
53
|
-
|
|
54
|
-
|
|
69
|
+
<% if strategy.logo? %>
|
|
70
|
+
<img src="<%= strategy.logo %>" alt="<%= strategy.logo_alt %>" />
|
|
71
|
+
<% end %>
|
|
72
|
+
<% if strategy.site_title? %>
|
|
73
|
+
<span><%= strategy.site_title %></span>
|
|
74
|
+
<% end %>
|
|
55
75
|
</a>
|
|
56
76
|
|
|
57
|
-
|
|
77
|
+
<% if strategy.search? %>
|
|
78
|
+
<a href="<%= relative_url '/search' %>" slot="search"><wa-icon label="<%= t "labels.search" %>" name="search"></wa-icon> <span class="hide-for-mobile"><%= t "labels.search" %> <kbd style="vertical-align: 10%">⌘K</kbd></span></a>
|
|
79
|
+
<% end %>
|
|
58
80
|
|
|
59
|
-
|
|
60
|
-
<!-- customize this list! -->
|
|
61
|
-
<li><a href="<%= relative_url '/blog' %>">Blog</a></li>
|
|
62
|
-
<li><a href="<%= relative_url '/about' %>">About</a></li>
|
|
63
|
-
<li><a href="#"><wa-icon label="Mastodon" family="brands" name="mastodon"></wa-icon></a></li>
|
|
64
|
-
</ul>
|
|
81
|
+
<%= strategy.nav_links %>
|
|
65
82
|
</header>
|
|
66
83
|
HTML
|
|
67
84
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Willamette
|
|
2
|
+
module Strategies
|
|
3
|
+
class Base
|
|
4
|
+
private
|
|
5
|
+
|
|
6
|
+
def links_html(links, slot: nil)
|
|
7
|
+
doc = Nokolexbor::HTML("<ul></ul>")
|
|
8
|
+
list = doc.at_css("ul")
|
|
9
|
+
list[:slot] = slot if slot
|
|
10
|
+
links.each_with_index do |link, index|
|
|
11
|
+
list << link_node(doc:, link:, folder: (links[index + 1]&.depth || 1) > link.depth)
|
|
12
|
+
end
|
|
13
|
+
list.to_html.html_safe
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def link_node(doc:, link:, folder: false) # rubocop:disable Metrics
|
|
17
|
+
item = doc.create_element("li")
|
|
18
|
+
item[:"item-depth"] = link.depth
|
|
19
|
+
anchor = doc.create_element("a")
|
|
20
|
+
anchor[:href] = @component.relative_url(link.url)
|
|
21
|
+
anchor[:"aria-current"] = "page" if link.current
|
|
22
|
+
|
|
23
|
+
if link.icon || respond_to?(:default_link_icon)
|
|
24
|
+
icon = doc.create_element("wa-icon")
|
|
25
|
+
icon[:name] = link.icon || default_link_icon(folder:)
|
|
26
|
+
icon[:family] = link.icon_family if link.icon_family
|
|
27
|
+
icon[:label] = link.icon_label if link.icon_label
|
|
28
|
+
anchor << icon
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
if link.title
|
|
32
|
+
anchor << doc.create_text_node(" ")
|
|
33
|
+
anchor << doc.create_text_node(link.title)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
item << anchor
|
|
37
|
+
item
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
module Willamette
|
|
2
2
|
# Contain logic for rendering
|
|
3
|
-
Strategies::Link = Data.define(
|
|
3
|
+
Strategies::Link = Data.define(
|
|
4
|
+
:depth, :current, :icon, :icon_family, :icon_label, :title, :url
|
|
5
|
+
)
|
|
4
6
|
|
|
5
|
-
def self.link(depth: 1, current: false, icon: nil, icon_family: nil, **) # rubocop:disable Metrics/ParameterLists
|
|
6
|
-
Strategies::Link.new(depth:, current:, icon:, icon_family:, **)
|
|
7
|
+
def self.link(depth: 1, current: false, icon: nil, icon_family: nil, icon_label: nil, **) # rubocop:disable Metrics/ParameterLists
|
|
8
|
+
Strategies::Link.new(depth:, current:, icon:, icon_family:, icon_label:, **)
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
def self.links_for(base_resource)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Willamette
|
|
2
|
+
# rubocop:disable Metrics/ParameterLists
|
|
3
|
+
module Strategies
|
|
4
|
+
# Contain logic for navbar rendering
|
|
5
|
+
class Navbar < Base
|
|
6
|
+
attr_reader :logo, :logo_alt, :site_title
|
|
7
|
+
|
|
8
|
+
# Use the `navbar` module method on `Willamette`
|
|
9
|
+
def initialize(
|
|
10
|
+
component, logo:, logo_alt:, site_title:, nav_links:, search:
|
|
11
|
+
)
|
|
12
|
+
@component = component
|
|
13
|
+
@logo = logo
|
|
14
|
+
@logo_alt = logo_alt
|
|
15
|
+
@site_title = site_title
|
|
16
|
+
@nav_links = nav_links
|
|
17
|
+
@search = search
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def logo? = @logo
|
|
21
|
+
|
|
22
|
+
def site_title? = @site_title
|
|
23
|
+
|
|
24
|
+
def search? = @search
|
|
25
|
+
|
|
26
|
+
def nav_links = links_html(@nav_links, slot: :nav)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.navbar(
|
|
31
|
+
component,
|
|
32
|
+
logo:,
|
|
33
|
+
site_title:,
|
|
34
|
+
nav_links:,
|
|
35
|
+
logo_alt: "logo",
|
|
36
|
+
search: true
|
|
37
|
+
)
|
|
38
|
+
Willamette::Strategies::Navbar.new(
|
|
39
|
+
component, logo:, logo_alt:, site_title:, nav_links:, search:
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
# rubocop:enable Metrics/ParameterLists
|
|
43
|
+
end
|
|
@@ -1,75 +1,47 @@
|
|
|
1
1
|
module Willamette
|
|
2
|
-
# Contain logic for rendering
|
|
3
2
|
# rubocop:disable Metrics/ParameterLists
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
module Strategies
|
|
4
|
+
# Contain logic for sidebar rendering
|
|
5
|
+
class Sidebar < Base
|
|
6
|
+
attr_reader :description
|
|
7
|
+
|
|
8
|
+
# Use the `sidebar` module method on `Willamette`
|
|
9
|
+
def initialize(
|
|
10
|
+
component, description:, explore_links:, follow_links:, subscribe:, see_also_links:
|
|
11
|
+
)
|
|
12
|
+
@component = component
|
|
13
|
+
@description = description
|
|
14
|
+
@explore_links = explore_links || []
|
|
15
|
+
@follow_links = follow_links || []
|
|
16
|
+
@subscribe = subscribe
|
|
17
|
+
@see_also_links = see_also_links || []
|
|
18
|
+
end
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
def explore? = !@explore_links.empty?
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
def explore_links = links_html(@explore_links)
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
def description? = @description && !explore?
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
def follow? = !@follow_links.empty?
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
def follow_links = links_html(@follow_links)
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
def subscribe? = @subscribe
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
def see_also? = !@see_also_links.empty?
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
folder ? "folder-open" : "file-lines"
|
|
37
|
-
end
|
|
34
|
+
def see_also_links = links_html(@see_also_links)
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def links_html(links)
|
|
42
|
-
doc = Nokolexbor::HTML("<ul></ul>")
|
|
43
|
-
list = doc.at_css("ul")
|
|
44
|
-
links.each_with_index do |link, index|
|
|
45
|
-
list << link_node(doc:, link:, folder: (links[index + 1]&.depth || 1) > link.depth)
|
|
36
|
+
def default_link_icon(folder: false)
|
|
37
|
+
folder ? "folder-open" : "file-lines"
|
|
46
38
|
end
|
|
47
|
-
list.to_html.html_safe
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def link_node(doc:, link:, folder: false) # rubocop:disable Metrics/AbcSize
|
|
51
|
-
item = doc.create_element("li")
|
|
52
|
-
item[:"item-depth"] = link.depth
|
|
53
|
-
anchor = doc.create_element("a")
|
|
54
|
-
anchor[:href] = @component.relative_url(link.url)
|
|
55
|
-
anchor[:"aria-current"] = "page" if link.current
|
|
56
|
-
|
|
57
|
-
icon = doc.create_element("wa-icon")
|
|
58
|
-
icon[:name] = link.icon || default_link_icon(folder:)
|
|
59
|
-
icon[:family] = link.icon_family if link.icon_family
|
|
60
|
-
anchor << icon
|
|
61
|
-
|
|
62
|
-
anchor << doc.create_text_node(" ")
|
|
63
|
-
anchor << doc.create_text_node(link.title)
|
|
64
|
-
|
|
65
|
-
item << anchor
|
|
66
|
-
item
|
|
67
39
|
end
|
|
68
40
|
end
|
|
69
41
|
|
|
70
42
|
def self.sidebar(
|
|
71
43
|
component,
|
|
72
|
-
description
|
|
44
|
+
description: nil,
|
|
73
45
|
explore_links: nil,
|
|
74
46
|
follow_links: nil,
|
|
75
47
|
subscribe: false,
|
data/lib/willamette/version.rb
CHANGED
data/lib/willamette.rb
CHANGED
|
@@ -13,7 +13,9 @@ end
|
|
|
13
13
|
require "willamette/builders/author_extension"
|
|
14
14
|
require "willamette/builders/inspectors"
|
|
15
15
|
require "willamette/builders/toc"
|
|
16
|
+
require "willamette/strategies/base"
|
|
16
17
|
require "willamette/strategies/link"
|
|
18
|
+
require "willamette/strategies/navbar"
|
|
17
19
|
require "willamette/strategies/sidebar"
|
|
18
20
|
|
|
19
21
|
# use `<wll-code>` element instead of `<div>`
|
data/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "willamette",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "willamette",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.9.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@awesome.me/webawesome": ">=3.6.0",
|
data/package.json
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: willamette
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bridgetown Team
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-05-
|
|
10
|
+
date: 2026-05-05 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: bridgetown
|
|
@@ -116,7 +116,9 @@ files:
|
|
|
116
116
|
- lib/willamette/builders/inspectors.rb
|
|
117
117
|
- lib/willamette/builders/toc.rb
|
|
118
118
|
- lib/willamette/locales/en.yml
|
|
119
|
+
- lib/willamette/strategies/base.rb
|
|
119
120
|
- lib/willamette/strategies/link.rb
|
|
121
|
+
- lib/willamette/strategies/navbar.rb
|
|
120
122
|
- lib/willamette/strategies/sidebar.rb
|
|
121
123
|
- lib/willamette/version.rb
|
|
122
124
|
- package-lock.json
|