Skip to content

Commit de1bb89

Browse files
NetdocsCopilot
andcommitted
refactor(theme): split content-actions, breadcrumbs, source-file partials
Break three sizable regions out of main.html into overridable partials so sites can restyle them without copying the whole layout: - partials/content-actions.html (Edit / View-source buttons) - partials/breadcrumbs.html (navigation.path trail) - partials/source-file.html (Last updated / Created line) Documented each in reference/theme.md. Verified edit/view buttons still render and breadcrumbs render when navigation.path is enabled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 08c8827 commit de1bb89

5 files changed

Lines changed: 63 additions & 32 deletions

File tree

docs-site/docs/reference/theme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ your `customDir` and it wins over the bundled version.
166166
| `partials/search.html` | Search box + results overlay markup. |
167167
| `partials/nav.html` | Sidebar navigation drawer. |
168168
| `partials/tabs.html` | Header tabs bar (only when `navigation.tabs` is off and you want a second row). |
169+
| `partials/content-actions.html` | Floating Edit / View-source buttons at the top-right of the article (`content.action.edit` / `content.action.view`). |
170+
| `partials/breadcrumbs.html` | Breadcrumb trail above the page title (`navigation.path`, driven by `breadcrumbs`). |
171+
| `partials/source-file.html` | "Last updated / Created" line under the article body (`show_source_meta`, non-post pages). |
169172
| `partials/toc.html` | Right-hand table of contents. |
170173
| `partials/footer.html` | Site footer: prev/next nav, copyright, social links. |
171174
| `partials/post-meta.html` | Blog-post byline: author avatar/name, date, reading time, categories. |

src/Netdocs.Theme.Material/templates/main.html

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -129,42 +129,13 @@
129129
{{~ end ~}}
130130
<div class="md-content" data-md-component="content">
131131
<article class="md-content__inner md-typeset">
132-
{{~ if (features | array.contains "content.action.edit") && edit_url ~}}
133-
<a href="{{ edit_url }}" title="Edit this page" class="md-content__button md-icon" rel="noopener" target="_blank">
134-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75z"/></svg>
135-
</a>
136-
{{~ end ~}}
137-
{{~ if (features | array.contains "content.action.view") && view_url ~}}
138-
<a href="{{ view_url }}" title="View source of this page" class="md-content__button md-icon" rel="noopener" target="_blank">
139-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 1 3 3 3 3 0 0 1-3 3 3 3 0 0 1-3-3 3 3 0 0 1 3-3m0-4.5c5 0 9.27 3.11 11 7.5-1.73 4.39-6 7.5-11 7.5S2.73 16.39 1 12c1.73-4.39 6-7.5 11-7.5M3.18 12a9.821 9.821 0 0 0 17.64 0 9.821 9.821 0 0 0-17.64 0"/></svg>
140-
</a>
141-
{{~ end ~}}
142-
{{~ if (features | array.contains "navigation.path") && breadcrumbs && (array.size breadcrumbs) > 0 ~}}
143-
<nav class="md-path" aria-label="Breadcrumb">
144-
<ul class="md-path__list">
145-
{{~ for crumb in breadcrumbs ~}}
146-
<li class="md-path__item">
147-
{{~ if crumb.url ~}}<a href="{{ base_url }}{{ crumb.url }}" class="md-path__link">{{ crumb.title }}</a>
148-
{{~ else ~}}<span class="md-path__link">{{ crumb.title }}</span>{{~ end ~}}
149-
</li>
150-
{{~ end ~}}
151-
</ul>
152-
</nav>
153-
{{~ end ~}}
132+
{{ include "partials/content-actions.html" }}
133+
{{ include "partials/breadcrumbs.html" }}
154134
{{~ if page.meta.is_post && page.meta.post_tags && (array.size page.meta.post_tags) > 0 ~}}
155135
<nav class="md-tags">{{~ for tag in page.meta.post_tags ~}}<a href="{{ base_url }}pages/tags/" class="md-tag">{{ tag }}</a> {{~ end ~}}</nav>
156136
{{~ end ~}}
157137
{{ content }}
158-
{{~ if show_source_meta && !page.meta.is_post ~}}
159-
<hr>
160-
<div class="md-source-file">
161-
<span class="md-source-file__fact">
162-
<span class="md-icon"></span>
163-
Last updated: {{ updated_display }}
164-
{{~ if created_display ~}} &middot; Created: {{ created_display }}{{~ end ~}}
165-
</span>
166-
</div>
167-
{{~ end ~}}
138+
{{ include "partials/source-file.html" }}
168139
</article>
169140
</div>
170141
</div>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{~ #
2+
# partials/breadcrumbs.html — Breadcrumb trail above the page title.
3+
#
4+
# Data: `breadcrumbs` — ordered list of { title, url } from the page's location in the nav.
5+
# `features` — gate on "navigation.path"; `base_url` — site root prefix for links.
6+
#
7+
# Override: drop a file at `<custom_dir>/partials/breadcrumbs.html`. Return nothing to hide.
8+
~}}
9+
{{~ if (features | array.contains "navigation.path") && breadcrumbs && (array.size breadcrumbs) > 0 ~}}
10+
<nav class="md-path" aria-label="Breadcrumb">
11+
<ul class="md-path__list">
12+
{{~ for crumb in breadcrumbs ~}}
13+
<li class="md-path__item">
14+
{{~ if crumb.url ~}}<a href="{{ base_url }}{{ crumb.url }}" class="md-path__link">{{ crumb.title }}</a>
15+
{{~ else ~}}<span class="md-path__link">{{ crumb.title }}</span>{{~ end ~}}
16+
</li>
17+
{{~ end ~}}
18+
</ul>
19+
</nav>
20+
{{~ end ~}}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{~ #
2+
# partials/content-actions.html — Floating "Edit"/"View source" buttons at the top-right
3+
# of the article. Shown when the matching feature is enabled and the page has a source URL.
4+
#
5+
# Data: `edit_url` / `view_url` — computed per page (empty for generated pages).
6+
# `features` — theme.features list; gate on "content.action.edit" / "content.action.view".
7+
#
8+
# Override: drop a file at `<custom_dir>/partials/content-actions.html`. Return nothing to hide.
9+
~}}
10+
{{~ if (features | array.contains "content.action.edit") && edit_url ~}}
11+
<a href="{{ edit_url }}" title="Edit this page" class="md-content__button md-icon" rel="noopener" target="_blank">
12+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75z"/></svg>
13+
</a>
14+
{{~ end ~}}
15+
{{~ if (features | array.contains "content.action.view") && view_url ~}}
16+
<a href="{{ view_url }}" title="View source of this page" class="md-content__button md-icon" rel="noopener" target="_blank">
17+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 1 3 3 3 3 0 0 1-3 3 3 3 0 0 1-3-3 3 3 0 0 1 3-3m0-4.5c5 0 9.27 3.11 11 7.5-1.73 4.39-6 7.5-11 7.5S2.73 16.39 1 12c1.73-4.39 6-7.5 11-7.5M3.18 12a9.821 9.821 0 0 0 17.64 0 9.821 9.821 0 0 0-17.64 0"/></svg>
18+
</a>
19+
{{~ end ~}}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{~ #
2+
# partials/source-file.html — "Last updated / Created" footer shown under the article body
3+
# for regular (non-post) pages when source metadata is available.
4+
#
5+
# Data: `show_source_meta` (bool), `updated_display`, `created_display`, `page.meta.is_post`.
6+
#
7+
# Override: drop a file at `<custom_dir>/partials/source-file.html`. Return nothing to hide.
8+
~}}
9+
{{~ if show_source_meta && !page.meta.is_post ~}}
10+
<hr>
11+
<div class="md-source-file">
12+
<span class="md-source-file__fact">
13+
<span class="md-icon"></span>
14+
Last updated: {{ updated_display }}
15+
{{~ if created_display ~}} &middot; Created: {{ created_display }}{{~ end ~}}
16+
</span>
17+
</div>
18+
{{~ end ~}}

0 commit comments

Comments
 (0)