feat(shell): two homes — masthead follows brand_href, opt-in app_link topbar link - #63
Merged
Merged
Conversation
… topbar link
## Summary
DocsUI::Page's masthead "← Home" hardcoded the host's `root_path` helper — on
a docs site embedded in a bigger app that's the application root (often an
authenticated dashboard), so readers were bounced off the docs, and sites had
to override the route helper to cope. The masthead now follows
`config.brand_href` (the DOCS home, same as the topbar/sidebar brand links),
relabeled "← Docs home". A new opt-in `c.app_link = { href:, label: }`
(default nil → absent) renders the way BACK to the hosting app once, in the
topbar right after the brand; external hrefs open in a new tab with
rel=noopener, mirroring TopbarLinks.
## Test Coverage
- configuration_spec: app_link defaults nil; Hash (symbol/string keys)
normalizes to DocsKit::TopbarLink; TopbarLink passes through
- shell_spec: unset → topbar unchanged; set → labeled anchor after the brand;
external → target=_blank + noopener; relative → neither
- page_spec: #home_href defaults "/" and follows c.brand_href (child-process
harness — Page can't load in the Rails-free suite)
- install_generator_spec: the generated initializer documents the commented
c.app_link example
## Verification
- [x] bundle exec rubocop passes
- [x] bundle exec rspec passes (795 examples, 94.87% line coverage)
Refs #62
mhenrixon
force-pushed
the
issue-62-app-link-docs-home
branch
from
August 2, 2026 18:37
7eeb15c to
7173abe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #62
Summary
DocsUI::Page's masthead "← Home" link hardcoded the host app'sroot_pathroute helper — the gem's only call site for it. On a docs site embedded in a bigger application,root_pathresolves to the application root (often an authenticated dashboard, not the docs landing), so readers clicking Home were bounced off the docs entirely, and a site's only recourse was overriding the route helper in its own view layer.This PR gives the chrome two config-driven homes:
config.brand_href(default"/"), the same knob the topbar and sidebar brand links already use, and is relabeled "← Docs home". A site that already setsc.brand_href = "/docs"gets the fix on upgrade with zero config change.c.app_link = { href:, label: }(defaultnil→ nothing renders). When set, the topbar renders a labeled link back to the hosting app once, right after the brand. Normalized through the existingDocsKit::TopbarLinkvalue object (symbol- or string-keyed Hash, or aTopbarLink); external hrefs open in a new tab withrel=noopener, mirroringDocsUI::TopbarLinks.Wired into the install path: the generated initializer documents the commented
c.app_linkexample (docs-kit newruns the same generator). README documents both homes.Backwards compatibility
app_linkunset → the topbar markup is byte-identical to before.brand_hrefdefault"/"→ the masthead points exactly whereroot_pathresolved on standalone sites; only the label changes ("← Home" → "← Docs home"), deliberately.@sourcechange needed.Phlex::Rails::Helpers::Routesstays included inPage— consuming sites call route helpers in#content.root_pathin their view layer can delete the override and, if they want the way back, setc.app_link.Test plan
spec/docs_kit/configuration_spec.rb—app_linkdefaults to nil; Hash (symbol/string keys) normalizes toDocsKit::TopbarLink; an existingTopbarLinkpasses through.spec/docs_ui/shell_spec.rb— unset → no App Home link; set → labeled anchor after the brand anchor; external href →target="_blank"+noopener; relative href → neither.spec/docs_ui/page_spec.rb—#home_hrefdefaults to"/"and followsc.brand_href(child-process harness;Pagecan't load in the Rails-free suite).spec/generators/install_generator_spec.rb— the generated initializer contains the commented# c.app_link =example.bundle exec rspec: 795 examples, 0 failures, 94.87% line coverage.bundle exec rubocop: clean.Deviations & judgment calls
bundle exec rubocopflaggedMetrics/ClassLengthonapp/components/docs_ui/shell.rb(105/100) after adding the ~10-line#app_home_linkmethod — Shell was already at the limit. Exemptedshell.rbin.rubocop.ymlalongsidelanding.rb, whose documented rationale (composite renderer of several sections, each a small focused method) applies verbatim. Alternatives rejected: compressing the method to dodge the metric (hurts readability), extracting a one-link component (over-engineering).