From 26ea09cce7187cc520c3305ca6642316ccb92bc2 Mon Sep 17 00:00:00 2001 From: Abdullah Hashim Date: Tue, 2 Jun 2026 13:23:39 -0400 Subject: [PATCH 1/6] Add sidebar navigation Introduces the defining feature of a docs theme: a left sidebar listing the site's pages, nested by front-matter, with the current page highlighted and collapsible parent sections. Pages opt out with `nav_exclude: true`. Within each level, pages are ordered by `nav_order` (unset values sort last alphabetically). Child pages declare their parent by title via `parent: "Title"`. The section containing the current page is auto-opened. The visual design is ported from just-the-docs' actual SCSS: exact color palette (#7253ed link, #f5f6fa sidebar, etc.), the calc-based responsive sidebar that grows with the viewport at the lg breakpoint (keeping the visible nav block visually centered with the content), gradient hover/active states, and JTD's typography scale. Collapsible sections use
, but the section link and the toggle are siblings inside the
  • rather than the link being nested inside the summary -- this avoids the "nested interactive controls" accessibility violation that the obvious structure produces. A regression test guards this. Co-Authored-By: Claude Opus 4.7 (1M context) --- components/bridgetown_stoa/sidebar.rb | 66 +++ components/bridgetown_stoa/sidebar.serb | 25 ++ frontend/styles/bridgetown-stoa.css | 389 +++++++++++++++++- layouts/bridgetown-stoa/layout.serb | 29 +- lib/bridgetown-stoa.rb | 3 +- test/fixtures/src/advanced.serb | 7 + test/fixtures/src/getting-started.serb | 7 + .../src/getting-started/configure.serb | 8 + .../fixtures/src/getting-started/install.serb | 8 + test/fixtures/src/hidden.serb | 7 + test/test_bridgetown_stoa.rb | 71 ++++ 11 files changed, 589 insertions(+), 31 deletions(-) create mode 100644 components/bridgetown_stoa/sidebar.rb create mode 100644 components/bridgetown_stoa/sidebar.serb create mode 100644 test/fixtures/src/advanced.serb create mode 100644 test/fixtures/src/getting-started.serb create mode 100644 test/fixtures/src/getting-started/configure.serb create mode 100644 test/fixtures/src/getting-started/install.serb create mode 100644 test/fixtures/src/hidden.serb diff --git a/components/bridgetown_stoa/sidebar.rb b/components/bridgetown_stoa/sidebar.rb new file mode 100644 index 0000000..97b4d3e --- /dev/null +++ b/components/bridgetown_stoa/sidebar.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +class BridgetownStoa::Sidebar < Bridgetown::Component + Node = Struct.new(:title, :url, :order, :parent_title, :current, :children, keyword_init: true) + + def initialize(site:, current_resource:) + super() + @site = site + @current_resource = current_resource + end + + def tree + @tree ||= build_tree + end + + def section_open?(node) + return true if node.current + + node.children.any? { |child| section_open?(child) } + end + + private + + def navigable_resources + @site.resources.select do |r| + next false if r.data[:nav_exclude] + next false unless r.data[:title] + next false unless r.output_ext == ".html" + + true + end + end + + def build_tree + nodes = navigable_resources.map { |r| build_node(r) } + by_title = nodes.to_h { |n| [n.title, n] } + + roots = nodes.each_with_object([]) do |node, acc| + parent = node.parent_title && by_title[node.parent_title] + if parent && parent != node + parent.children << node + else + acc << node + end + end + + sort_nodes!(roots) + roots + end + + def build_node(resource) + Node.new( + title: resource.data[:title], + url: resource.relative_url, + order: resource.data[:nav_order], + parent_title: resource.data[:parent], + current: resource == @current_resource, + children: [] + ) + end + + def sort_nodes!(nodes) + nodes.sort_by! { |n| [n.order || Float::INFINITY, n.title.to_s.downcase] } + nodes.each { |n| sort_nodes!(n.children) } + end +end diff --git a/components/bridgetown_stoa/sidebar.serb b/components/bridgetown_stoa/sidebar.serb new file mode 100644 index 0000000..8bca726 --- /dev/null +++ b/components/bridgetown_stoa/sidebar.serb @@ -0,0 +1,25 @@ +
  • + + {% else %} +
  • + {{ node.title }} +
  • + {% end %} + {% end %} + + diff --git a/frontend/styles/bridgetown-stoa.css b/frontend/styles/bridgetown-stoa.css index d71f4c5..45c710c 100644 --- a/frontend/styles/bridgetown-stoa.css +++ b/frontend/styles/bridgetown-stoa.css @@ -1,34 +1,387 @@ -/* bridgetown-stoa: Tailwind v4 source partial. Import after `@import "tailwindcss"`. */ +/* bridgetown-stoa: Tailwind v4 source partial. Import after `@import "tailwindcss"`. + * Layout and colors mirror just-the-docs (https://github.com/just-the-docs/just-the-docs). + */ @custom-variant dark (&:where(.dark, .dark *)); @theme { - --color-stoa-bg: oklch(98% 0.002 264); - --color-stoa-surface: oklch(100% 0 0); - --color-stoa-fg: oklch(20% 0.012 264); - --color-stoa-muted: oklch(50% 0.012 264); - --color-stoa-border: oklch(92% 0.005 264); - --color-stoa-accent: oklch(55% 0.18 264); - --color-stoa-accent-fg: oklch(98% 0.002 264); - - --font-stoa-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; - --font-stoa-mono: ui-monospace, "SF Mono", Menlo, "Cascadia Code", monospace; + --color-stoa-bg: #ffffff; + --color-stoa-sidebar: #f5f6fa; + --color-stoa-feedback: #ebedf2; + --color-stoa-fg: #5c5962; + --color-stoa-heading: #27262b; + --color-stoa-muted: #959396; + --color-stoa-border: #eeebee; + --color-stoa-link: #7253ed; + --color-stoa-link-hover: #5e41d0; + --color-stoa-code-bg: #ffffff; + + --font-stoa-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; + --font-stoa-mono: "SFMono-Regular", Menlo, Consolas, monospace; + + --stoa-nav-width: 16.5rem; + --stoa-nav-width-md: 15.5rem; + --stoa-content-width: 50rem; + --stoa-header-height: 3.75rem; + --stoa-gutter: 2rem; + --stoa-gutter-sm: 1rem; } @layer base { .dark { - --color-stoa-bg: oklch(17% 0.012 264); - --color-stoa-surface: oklch(22% 0.012 264); - --color-stoa-fg: oklch(94% 0.005 264); - --color-stoa-muted: oklch(65% 0.012 264); - --color-stoa-border: oklch(28% 0.012 264); - --color-stoa-accent: oklch(72% 0.16 264); - --color-stoa-accent-fg: oklch(15% 0.012 264); + --color-stoa-bg: #27262b; + --color-stoa-sidebar: #2e2c33; + --color-stoa-feedback: #3a3742; + --color-stoa-fg: #bdbabf; + --color-stoa-heading: #ffffff; + --color-stoa-muted: #8d8a93; + --color-stoa-border: #44434d; + --color-stoa-link: #b384f3; + --color-stoa-link-hover: #c8a4ff; + --color-stoa-code-bg: #302d36; } html { background: var(--color-stoa-bg); color: var(--color-stoa-fg); font-family: var(--font-stoa-sans); + font-size: 0.875rem; + line-height: 1.4; + } + + @media (min-width: 31.25rem) { + html { + font-size: 1rem; + } + } + + /* Sidebar shell (mobile-first: stacked above main) */ + .stoa-sidebar-shell { + display: flex; + flex-direction: column; + background: var(--color-stoa-sidebar); + } + + .stoa-main { + margin: auto; + } + + /* md: sidebar fixed left at 15.5rem, main has matching margin */ + @media (min-width: 50rem) { + .stoa-sidebar-shell { + position: fixed; + top: 0; + left: 0; + width: var(--stoa-nav-width-md); + height: 100%; + border-right: 1px solid var(--color-stoa-border); + align-items: flex-end; + } + + .stoa-main { + position: relative; + max-width: var(--stoa-content-width); + margin-left: var(--stoa-nav-width-md); + } + } + + /* lg: sidebar grows with viewport; nav content stays 16.5rem right-aligned */ + @media (min-width: 66.5rem) { + .stoa-sidebar-shell { + width: calc((100% - (var(--stoa-nav-width) + var(--stoa-content-width))) / 2 + var(--stoa-nav-width)); + min-width: var(--stoa-nav-width); + } + + .stoa-main { + margin-left: max( + var(--stoa-nav-width), + calc((100% - (var(--stoa-nav-width) + var(--stoa-content-width))) / 2 + var(--stoa-nav-width)) + ); + } + } + + /* Inner sidebar sections: full width on mobile; fixed 16.5rem (right-aligned) at lg */ + .stoa-brand, + .stoa-sidebar, + .stoa-sidebar-footer { + width: 100%; + } + + @media (min-width: 66.5rem) { + .stoa-brand, + .stoa-sidebar, + .stoa-sidebar-footer { + width: var(--stoa-nav-width); + } + } + + /* Brand area at top of sidebar */ + .stoa-brand { + display: flex; + min-height: var(--stoa-header-height); + align-items: center; + padding: 0 var(--stoa-gutter-sm); + } + + @media (min-width: 50rem) { + .stoa-brand { + padding: 0 var(--stoa-gutter); + border-bottom: 1px solid var(--color-stoa-border); + } + } + + .stoa-site-title { + color: var(--color-stoa-heading); + font-size: 1.125rem; + font-weight: 400; + text-decoration: none; + } + + @media (min-width: 31.25rem) { + .stoa-site-title { + font-size: 1.5rem; + } + } + + /* Site nav */ + .stoa-sidebar { + flex: 1 1 auto; + overflow-y: auto; + padding-top: var(--stoa-gutter); + padding-bottom: var(--stoa-gutter-sm); + } + + .stoa-sidebar ul { + list-style: none; + padding: 0; + margin: 0; + } + + .stoa-sidebar li { + position: relative; + margin: 0; + } + + .stoa-sidebar a { + display: block; + color: var(--color-stoa-fg); + text-decoration: none; + min-height: 2rem; + line-height: 1.5rem; + padding: 0.25rem 2rem 0.25rem var(--stoa-gutter-sm); + } + + @media (min-width: 50rem) { + .stoa-sidebar a { + padding-left: var(--stoa-gutter); + } + } + + .stoa-sidebar a:hover, + .stoa-sidebar a[aria-current="page"] { + color: var(--color-stoa-link-hover); + background-image: linear-gradient( + -90deg, + var(--color-stoa-feedback) 0%, + color-mix(in srgb, var(--color-stoa-feedback) 80%, transparent) 80%, + transparent 100% + ); + } + + .stoa-sidebar a[aria-current="page"] { + font-weight: 600; + } + + .stoa-sidebar ul ul { + padding-left: 0.75rem; + } + + /* Collapsible parent sections: link + details (with toggle summary) as siblings */ + .stoa-sidebar .stoa-nav-parent { + position: relative; + } + + .stoa-sidebar .stoa-nav-parent > details > summary { + list-style: none; + cursor: pointer; + position: absolute; + top: 0; + right: 0; + width: 2rem; + height: 2rem; + display: flex; + align-items: center; + justify-content: center; + color: var(--color-stoa-link); + } + + .stoa-sidebar .stoa-nav-parent > details > summary::-webkit-details-marker { display: none; } + + .stoa-sidebar .stoa-nav-parent > details > summary::after { + content: ""; + width: 0.5rem; + height: 0.5rem; + border-top: 1.5px solid currentColor; + border-right: 1.5px solid currentColor; + transform: rotate(45deg); + transition: transform 0.15s ease; + } + + .stoa-sidebar .stoa-nav-parent > details[open] > summary::after { + transform: rotate(135deg); + } + + .stoa-sidebar .stoa-nav-parent > details > summary:hover { + background-image: linear-gradient( + -90deg, + var(--color-stoa-feedback) 0%, + color-mix(in srgb, var(--color-stoa-feedback) 80%, transparent) 100% + ); + } + + /* Footer pinned to the bottom of the sidebar */ + .stoa-sidebar-footer { + padding: var(--stoa-gutter-sm); + font-size: 0.6875rem; + } + + @media (min-width: 31.25rem) { + .stoa-sidebar-footer { + font-size: 0.75rem; + } + } + + @media (min-width: 50rem) { + .stoa-sidebar-footer { + padding-left: var(--stoa-gutter); + padding-right: var(--stoa-gutter); + } + } + + .stoa-sidebar-footer a { + color: var(--color-stoa-link); + text-decoration: underline; + text-decoration-color: var(--color-stoa-border); + text-underline-offset: 2px; + } + + /* Main content area */ + .stoa-content { + padding: var(--stoa-gutter-sm); + } + + @media (min-width: 50rem) { + .stoa-content { + padding: var(--stoa-gutter); + } + } + + .stoa-content h1, + .stoa-content h2, + .stoa-content h3, + .stoa-content h4, + .stoa-content h5, + .stoa-content h6 { + color: var(--color-stoa-heading); + font-weight: 500; + line-height: 1.25; + margin: 0 0 1em; + } + + .stoa-content h1 { + font-weight: 300; + font-size: 2rem; + } + + @media (min-width: 31.25rem) { + .stoa-content h1 { font-size: 2.25rem; } + } + + .stoa-content h2 { font-size: 1.125rem; } + + @media (min-width: 31.25rem) { + .stoa-content h2 { font-size: 1.5rem; } + } + + .stoa-content h3 { font-size: 1rem; } + + @media (min-width: 31.25rem) { + .stoa-content h3 { font-size: 1.125rem; } + } + + .stoa-content h4 { + font-size: 0.6875rem; + font-weight: 400; + text-transform: uppercase; + letter-spacing: 0.1em; + } + + @media (min-width: 31.25rem) { + .stoa-content h4 { font-size: 0.75rem; } + } + + .stoa-content p, + .stoa-content ul, + .stoa-content ol, + .stoa-content blockquote, + .stoa-content pre, + .stoa-content table { + margin: 1em 0; + line-height: 1.6; + } + + .stoa-content ul, + .stoa-content ol { + padding-left: 1.5rem; + } + + .stoa-content li { margin: 0.25em 0; } + + .stoa-content a { + color: var(--color-stoa-link); + text-decoration: underline; + text-decoration-color: var(--color-stoa-border); + text-underline-offset: 2px; + } + + .stoa-content a:hover { + text-decoration-color: color-mix(in srgb, var(--color-stoa-link) 45%, transparent); + } + + .stoa-content code { + font-family: var(--font-stoa-mono); + font-size: 0.75em; + background: var(--color-stoa-code-bg); + border: 1px solid var(--color-stoa-border); + border-radius: 4px; + padding: 0.125rem 0.375rem; + } + + .stoa-content pre { + background: var(--color-stoa-code-bg); + border: 1px solid var(--color-stoa-border); + border-radius: 4px; + padding: 0.75rem; + overflow-x: auto; + line-height: 1.4; + } + + .stoa-content pre code { + background: transparent; + border: 0; + padding: 0; + font-size: inherit; + } + + .stoa-content blockquote { + padding-left: 1rem; + border-left: 3px solid var(--color-stoa-border); + } + + .stoa-content hr { + height: 1px; + border: 0; + background: var(--color-stoa-border); + margin: 2rem 0; } } diff --git a/layouts/bridgetown-stoa/layout.serb b/layouts/bridgetown-stoa/layout.serb index 16268cd..4295218 100644 --- a/layouts/bridgetown-stoa/layout.serb +++ b/layouts/bridgetown-stoa/layout.serb @@ -14,20 +14,25 @@ {% end %} - -
    - {{ site.metadata.title }} -
    + +
    - {%= yield %} +
    + {%= yield %} +
    - diff --git a/lib/bridgetown-stoa.rb b/lib/bridgetown-stoa.rb index 30972c3..925572f 100644 --- a/lib/bridgetown-stoa.rb +++ b/lib/bridgetown-stoa.rb @@ -15,6 +15,7 @@ config.source_manifest( origin: BridgetownStoa, - layouts: File.expand_path("../layouts", __dir__) + layouts: File.expand_path("../layouts", __dir__), + components: File.expand_path("../components", __dir__) ) end diff --git a/test/fixtures/src/advanced.serb b/test/fixtures/src/advanced.serb new file mode 100644 index 0000000..a062b4b --- /dev/null +++ b/test/fixtures/src/advanced.serb @@ -0,0 +1,7 @@ +--- +layout: bridgetown-stoa/layout +title: Advanced +nav_order: 2 +--- + +Advanced topics. diff --git a/test/fixtures/src/getting-started.serb b/test/fixtures/src/getting-started.serb new file mode 100644 index 0000000..8ee4c63 --- /dev/null +++ b/test/fixtures/src/getting-started.serb @@ -0,0 +1,7 @@ +--- +layout: bridgetown-stoa/layout +title: Getting Started +nav_order: 1 +--- + +Getting started. diff --git a/test/fixtures/src/getting-started/configure.serb b/test/fixtures/src/getting-started/configure.serb new file mode 100644 index 0000000..ab6bfeb --- /dev/null +++ b/test/fixtures/src/getting-started/configure.serb @@ -0,0 +1,8 @@ +--- +layout: bridgetown-stoa/layout +title: Configure +parent: Getting Started +nav_order: 2 +--- + +Configuration. diff --git a/test/fixtures/src/getting-started/install.serb b/test/fixtures/src/getting-started/install.serb new file mode 100644 index 0000000..80e28e5 --- /dev/null +++ b/test/fixtures/src/getting-started/install.serb @@ -0,0 +1,8 @@ +--- +layout: bridgetown-stoa/layout +title: Install +parent: Getting Started +nav_order: 1 +--- + +Install instructions. diff --git a/test/fixtures/src/hidden.serb b/test/fixtures/src/hidden.serb new file mode 100644 index 0000000..b915591 --- /dev/null +++ b/test/fixtures/src/hidden.serb @@ -0,0 +1,7 @@ +--- +layout: bridgetown-stoa/layout +title: Hidden +nav_exclude: true +--- + +This page should not appear in the sidebar. diff --git a/test/test_bridgetown_stoa.rb b/test/test_bridgetown_stoa.rb index b804c63..d488764 100644 --- a/test/test_bridgetown_stoa.rb +++ b/test/test_bridgetown_stoa.rb @@ -42,9 +42,80 @@ def setup it "renders semantic chrome around yielded content" do assert_match(%r{]}, @contents) + assert_match(%r{]}, @contents) assert_match(%r{]}, @contents) assert_match(%r{]}, @contents) assert_includes @contents, "Testing this plugin." end end + + describe "sidebar navigation" do # rubocop:disable Metrics/BlockLength + before do + @contents = File.read(dest_dir("index.html")) + end + + it "lists top-level pages as sidebar links" do + assert_match(%r{]*href="/about/?"[^>]*>\s*About\s*}, @contents) + assert_match(%r{]*href="/getting-started/?"[^>]*>\s*Getting Started\s*}, @contents) + assert_match(%r{]*href="/advanced/?"[^>]*>\s*Advanced\s*}, @contents) + end + + it "orders pages by nav_order, then unordered pages alphabetically" do + positions = ["Getting Started", "Advanced", ">About<", ">Index<"].map do |needle| + @contents.index(needle) + end + assert positions.none?(&:nil?), "missing sidebar entry: #{positions.inspect}" + assert_equal positions, positions.sort, "sidebar order wrong: #{positions.inspect}" + end + + it "nests child pages under their declared parent" do + assert_match( + %r{Getting Started\s*.*?
      .*?Install.*?Configure.*?
    }m, + @contents + ) + end + + it "wraps parent sections in
    with the current section open" do + install_html = File.read(dest_dir("getting-started/install/index.html")) + pattern = %r{ + Getting\sStarted\s*\s* + ]*>.*? + ]*>.*? + Install.*? +
    + }mx + assert_match(pattern, install_html) + end + + it "leaves non-current sections collapsed by default" do + assert_match( + %r{Getting Started\s*\s*]*)?>\s*]*>}m, + @contents + ) + refute_match(%r{Getting Started\s*\s*]*>\s*]}, @contents) + end + + it "sorts children by nav_order" do + install_pos = @contents.index(">Install<") + configure_pos = @contents.index(">Configure<") + assert install_pos && configure_pos + assert install_pos < configure_pos + end + + it "omits pages marked nav_exclude" do + refute_match(%r{>Hidden<}, @contents) + end + + it "marks the current page with aria-current" do + gs_html = File.read(dest_dir("getting-started/index.html")) + assert_match( + %r{href="/getting-started/?"[^>]*aria-current="page"[^>]*>\s*Getting Started\s*}, + gs_html + ) + end + end end From 616f5808ea4dc57cbfb8467453ce0eea70db0acf Mon Sep 17 00:00:00 2001 From: Abdullah Hashim Date: Tue, 2 Jun 2026 13:44:12 -0400 Subject: [PATCH 2/6] Bump text and link colors to meet WCAG AAA contrast The JTD palette we ported targets WCAG AA (4.5:1). Several tokens land just below the AAA threshold (7:1) -- body text at 6.4:1, link color at 5.1:1 on white, and the dark-mode link at 6.75:1 on the sidebar. axe (with AAA enabled) flagged these across the sidebar links, the active link, the footer links, and the body text. Darken light-mode --color-stoa-fg, --color-stoa-link, --color-stoa-link-hover, and --color-stoa-muted (all to neighboring JTD palette steps where possible -- grey-dk-200, purple-200, purple-300). Lighten the dark-mode link tokens correspondingly. Co-Authored-By: Claude Opus 4.7 (1M context) --- frontend/styles/bridgetown-stoa.css | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/styles/bridgetown-stoa.css b/frontend/styles/bridgetown-stoa.css index 45c710c..6aa4033 100644 --- a/frontend/styles/bridgetown-stoa.css +++ b/frontend/styles/bridgetown-stoa.css @@ -8,12 +8,12 @@ --color-stoa-bg: #ffffff; --color-stoa-sidebar: #f5f6fa; --color-stoa-feedback: #ebedf2; - --color-stoa-fg: #5c5962; + --color-stoa-fg: #44434d; --color-stoa-heading: #27262b; - --color-stoa-muted: #959396; + --color-stoa-muted: #4f4d56; --color-stoa-border: #eeebee; - --color-stoa-link: #7253ed; - --color-stoa-link-hover: #5e41d0; + --color-stoa-link: #4e26af; + --color-stoa-link-hover: #381885; --color-stoa-code-bg: #ffffff; --font-stoa-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; @@ -32,12 +32,12 @@ --color-stoa-bg: #27262b; --color-stoa-sidebar: #2e2c33; --color-stoa-feedback: #3a3742; - --color-stoa-fg: #bdbabf; + --color-stoa-fg: #d6d4d9; --color-stoa-heading: #ffffff; - --color-stoa-muted: #8d8a93; + --color-stoa-muted: #c2bec7; --color-stoa-border: #44434d; - --color-stoa-link: #b384f3; - --color-stoa-link-hover: #c8a4ff; + --color-stoa-link: #d8bcff; + --color-stoa-link-hover: #ebd7ff; --color-stoa-code-bg: #302d36; } From 49d25c10c25804286e86ea52e6dbbfbf93e6bcb4 Mon Sep 17 00:00:00 2001 From: Abdullah Hashim Date: Tue, 2 Jun 2026 16:57:02 -0400 Subject: [PATCH 3/6] wip --- test/test_bridgetown_stoa.rb | 70 --------------------------- test/test_sidebar.rb | 91 ++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 70 deletions(-) create mode 100644 test/test_sidebar.rb diff --git a/test/test_bridgetown_stoa.rb b/test/test_bridgetown_stoa.rb index d488764..78eb966 100644 --- a/test/test_bridgetown_stoa.rb +++ b/test/test_bridgetown_stoa.rb @@ -48,74 +48,4 @@ def setup assert_includes @contents, "Testing this plugin." end end - - describe "sidebar navigation" do # rubocop:disable Metrics/BlockLength - before do - @contents = File.read(dest_dir("index.html")) - end - - it "lists top-level pages as sidebar links" do - assert_match(%r{]*href="/about/?"[^>]*>\s*About\s*}, @contents) - assert_match(%r{]*href="/getting-started/?"[^>]*>\s*Getting Started\s*}, @contents) - assert_match(%r{]*href="/advanced/?"[^>]*>\s*Advanced\s*}, @contents) - end - - it "orders pages by nav_order, then unordered pages alphabetically" do - positions = ["Getting Started", "Advanced", ">About<", ">Index<"].map do |needle| - @contents.index(needle) - end - assert positions.none?(&:nil?), "missing sidebar entry: #{positions.inspect}" - assert_equal positions, positions.sort, "sidebar order wrong: #{positions.inspect}" - end - - it "nests child pages under their declared parent" do - assert_match( - %r{Getting Started\s*.*?
      .*?Install.*?Configure.*?
    }m, - @contents - ) - end - - it "wraps parent sections in
    with the current section open" do - install_html = File.read(dest_dir("getting-started/install/index.html")) - pattern = %r{ - Getting\sStarted\s*\s* - ]*>.*? - ]*>.*? - Install.*? -
    - }mx - assert_match(pattern, install_html) - end - - it "leaves non-current sections collapsed by default" do - assert_match( - %r{Getting Started\s*\s*]*)?>\s*]*>}m, - @contents - ) - refute_match(%r{Getting Started\s*\s*]*>\s*]}, @contents) - end - - it "sorts children by nav_order" do - install_pos = @contents.index(">Install<") - configure_pos = @contents.index(">Configure<") - assert install_pos && configure_pos - assert install_pos < configure_pos - end - - it "omits pages marked nav_exclude" do - refute_match(%r{>Hidden<}, @contents) - end - - it "marks the current page with aria-current" do - gs_html = File.read(dest_dir("getting-started/index.html")) - assert_match( - %r{href="/getting-started/?"[^>]*aria-current="page"[^>]*>\s*Getting Started\s*}, - gs_html - ) - end - end end diff --git a/test/test_sidebar.rb b/test/test_sidebar.rb new file mode 100644 index 0000000..05849a8 --- /dev/null +++ b/test/test_sidebar.rb @@ -0,0 +1,91 @@ +# frozen_string_literal: true + +require_relative "helper" + +class TestSidebar < Bridgetown::TestCase + def setup + Bridgetown.reset_configuration! + @config = Bridgetown.configuration( + "root_dir" => root_dir, + "source" => source_dir, + "destination" => dest_dir, + "quiet" => true + ) + @config.run_initializers! context: :static + @site = Bridgetown::Site.new(@config) + + with_metadata title: "My Awesome Site" do + @site.process + end + end + + describe "sidebar navigation" do # rubocop:disable Metrics/BlockLength + before do + @contents = File.read(dest_dir("index.html")) + end + + it "lists top-level pages as sidebar links" do + assert_match(%r{]*href="/about/?"[^>]*>\s*About\s*}, @contents) + assert_match(%r{]*href="/getting-started/?"[^>]*>\s*Getting Started\s*}, @contents) + assert_match(%r{]*href="/advanced/?"[^>]*>\s*Advanced\s*}, @contents) + end + + it "orders pages by nav_order, then unordered pages alphabetically" do + positions = ["Getting Started", "Advanced", ">About<", ">Index<"].map do |needle| + @contents.index(needle) + end + assert positions.none?(&:nil?), "missing sidebar entry: #{positions.inspect}" + assert_equal positions, positions.sort, "sidebar order wrong: #{positions.inspect}" + end + + it "nests child pages under their declared parent" do + assert_match( + %r{Getting Started\s*.*?
      .*?Install.*?Configure.*?
    }m, + @contents + ) + end + + it "wraps parent sections in
    with the current section open" do + install_html = File.read(dest_dir("getting-started/install/index.html")) + pattern = %r{ + Getting\sStarted\s*\s* + ]*>.*? + ]*>.*? + Install.*? +
    + }mx + assert_match(pattern, install_html) + end + + it "leaves non-current sections collapsed by default" do + assert_match( + %r{Getting Started\s*\s*]*)?>\s*]*>}m, + @contents + ) + refute_match(%r{Getting Started\s*\s*]*>\s*]}, @contents) + end + + it "sorts children by nav_order" do + install_pos = @contents.index(">Install<") + configure_pos = @contents.index(">Configure<") + assert install_pos && configure_pos + assert install_pos < configure_pos + end + + it "omits pages marked nav_exclude" do + refute_match(%r{>Hidden<}, @contents) + end + + it "marks the current page with aria-current" do + gs_html = File.read(dest_dir("getting-started/index.html")) + assert_match( + %r{href="/getting-started/?"[^>]*aria-current="page"[^>]*>\s*Getting Started\s*}, + gs_html + ) + end + end +end From 69ede5b1b38c5db321e9bec290a344e286353342 Mon Sep 17 00:00:00 2001 From: Abdullah Hashim Date: Tue, 2 Jun 2026 17:04:48 -0400 Subject: [PATCH 4/6] wip --- .rubocop.yml | 4 ++++ test/helper.rb | 16 ++++++++++++++++ test/test_bridgetown_stoa.rb | 16 ---------------- test/test_sidebar.rb | 18 +----------------- 4 files changed, 21 insertions(+), 33 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 17ddd4e..dd04d06 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,3 +21,7 @@ AllCops: - script/**/* - test/fixtures/**/* - vendor/**/* + +Metrics/BlockLength: + Exclude: + - "test/**/*" diff --git a/test/helper.rb b/test/helper.rb index 73ee1c8..ae54b65 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -54,5 +54,21 @@ def with_metadata(data = {}) source_dir("_data/site_metadata.yml") ) end + + def setup + Bridgetown.reset_configuration! + @config = Bridgetown.configuration( + "root_dir" => root_dir, + "source" => source_dir, + "destination" => dest_dir, + "quiet" => true + ) + @config.run_initializers! context: :static + @site = Bridgetown::Site.new(@config) + + with_metadata title: "My Awesome Site" do + @site.process + end + end end end diff --git a/test/test_bridgetown_stoa.rb b/test/test_bridgetown_stoa.rb index 78eb966..f45d3c2 100644 --- a/test/test_bridgetown_stoa.rb +++ b/test/test_bridgetown_stoa.rb @@ -3,22 +3,6 @@ require_relative "helper" class TestBridgetownStoa < Bridgetown::TestCase - def setup - Bridgetown.reset_configuration! - @config = Bridgetown.configuration( - "root_dir" => root_dir, - "source" => source_dir, - "destination" => dest_dir, - "quiet" => true - ) - @config.run_initializers! context: :static - @site = Bridgetown::Site.new(@config) - - with_metadata title: "My Awesome Site" do - @site.process - end - end - describe "BridgetownStoa" do before do @contents = File.read(dest_dir("index.html")) diff --git a/test/test_sidebar.rb b/test/test_sidebar.rb index 05849a8..323cd78 100644 --- a/test/test_sidebar.rb +++ b/test/test_sidebar.rb @@ -3,23 +3,7 @@ require_relative "helper" class TestSidebar < Bridgetown::TestCase - def setup - Bridgetown.reset_configuration! - @config = Bridgetown.configuration( - "root_dir" => root_dir, - "source" => source_dir, - "destination" => dest_dir, - "quiet" => true - ) - @config.run_initializers! context: :static - @site = Bridgetown::Site.new(@config) - - with_metadata title: "My Awesome Site" do - @site.process - end - end - - describe "sidebar navigation" do # rubocop:disable Metrics/BlockLength + describe "sidebar navigation" do before do @contents = File.read(dest_dir("index.html")) end From 43e0de10a80645743cdeb1890356b4119054967f Mon Sep 17 00:00:00 2001 From: Abdullah Hashim Date: Thu, 24 Sep 2026 09:23:39 -0400 Subject: [PATCH 5/6] wip --- test/test_sidebar.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/test_sidebar.rb b/test/test_sidebar.rb index 323cd78..dbb9cb2 100644 --- a/test/test_sidebar.rb +++ b/test/test_sidebar.rb @@ -9,7 +9,7 @@ class TestSidebar < Bridgetown::TestCase end it "lists top-level pages as sidebar links" do - assert_match(%r{]*href="/about/?"[^>]*>\s*About\s*}, @contents) + assert_match(%r{]*href="/about/?"[^>]*>\s*About\s*}, contents) assert_match(%r{]*href="/getting-started/?"[^>]*>\s*Getting Started\s*}, @contents) assert_match(%r{]*href="/advanced/?"[^>]*>\s*Advanced\s*}, @contents) end @@ -71,5 +71,11 @@ class TestSidebar < Bridgetown::TestCase gs_html ) end + + private + + def contents + @contents ||= File.read(dest_dir("index.html")) + end end end From af78363dc5ae798d3b0f6c8b4160d4ab2d073cae Mon Sep 17 00:00:00 2001 From: Abdullah Hashim Date: Thu, 24 Sep 2026 09:53:23 -0400 Subject: [PATCH 6/6] Derive theme colors from the Guided Rails brand color Replace the ported just-the-docs purple/grey palette with one built from the Guided Rails brand color (#7a1f5c, guidedrails.com). Links use it directly; sidebar, feedback, border, and text tokens are tinted toward its hue in OKLCH, in both light and dark mode. Every text/background pair still meets WCAG AAA (7:1). Muted text on the feedback background was the tightest pair and got nudged a step. --- frontend/styles/bridgetown-stoa.css | 39 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/frontend/styles/bridgetown-stoa.css b/frontend/styles/bridgetown-stoa.css index 6aa4033..0e9f560 100644 --- a/frontend/styles/bridgetown-stoa.css +++ b/frontend/styles/bridgetown-stoa.css @@ -1,19 +1,22 @@ /* bridgetown-stoa: Tailwind v4 source partial. Import after `@import "tailwindcss"`. - * Layout and colors mirror just-the-docs (https://github.com/just-the-docs/just-the-docs). + * Layout mirrors just-the-docs (https://github.com/just-the-docs/just-the-docs). + * Colors derive from the Guided Rails brand color (#7a1f5c, guidedrails.com): links use it + * directly, neutrals are tinted toward its hue in OKLCH, and every text/background pair + * meets WCAG AAA (7:1). */ @custom-variant dark (&:where(.dark, .dark *)); @theme { --color-stoa-bg: #ffffff; - --color-stoa-sidebar: #f5f6fa; - --color-stoa-feedback: #ebedf2; - --color-stoa-fg: #44434d; - --color-stoa-heading: #27262b; - --color-stoa-muted: #4f4d56; - --color-stoa-border: #eeebee; - --color-stoa-link: #4e26af; - --color-stoa-link-hover: #381885; + --color-stoa-sidebar: #f8f4f6; + --color-stoa-feedback: #f1e8ed; + --color-stoa-fg: #4a3e45; + --color-stoa-heading: #31212a; + --color-stoa-muted: #53464d; + --color-stoa-border: #ede5e9; + --color-stoa-link: #7a1f5c; + --color-stoa-link-hover: #610046; --color-stoa-code-bg: #ffffff; --font-stoa-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; @@ -29,16 +32,16 @@ @layer base { .dark { - --color-stoa-bg: #27262b; - --color-stoa-sidebar: #2e2c33; - --color-stoa-feedback: #3a3742; - --color-stoa-fg: #d6d4d9; + --color-stoa-bg: #261c22; + --color-stoa-sidebar: #2e2229; + --color-stoa-feedback: #3c2e36; + --color-stoa-fg: #d9d2d6; --color-stoa-heading: #ffffff; - --color-stoa-muted: #c2bec7; - --color-stoa-border: #44434d; - --color-stoa-link: #d8bcff; - --color-stoa-link-hover: #ebd7ff; - --color-stoa-code-bg: #302d36; + --color-stoa-muted: #ccc0c6; + --color-stoa-border: #52424b; + --color-stoa-link: #f5b3d9; + --color-stoa-link-hover: #fccfe8; + --color-stoa-code-bg: #30252b; } html {