Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show anchor links on headings #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion input/Shared/_ChildPages.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.ToDocumentList();
@if (!Document.GetBool(SiteKeys.NoChildPages) && children.Count > 0)
{
<h4 class="h-section mb-2">Child Pages</h4>
<h4 class="h-section mb-2 no-anchor">Child Pages</h4>
@foreach (IDocument child in children)
{
<div>
Expand Down
2 changes: 1 addition & 1 deletion input/Shared/_ChildPagesItem.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@{
string excerpt = Model.GetString(Keys.Excerpt);
<div class="p-3 mb-2 bg-light page-box">
<h4>@Html.DocumentLink(Model)</h4>
<h4 class="no-anchor">@Html.DocumentLink(Model)</h4>

@if (!string.IsNullOrEmpty(excerpt))
{
Expand Down
4 changes: 4 additions & 0 deletions input/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-core.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/plugins/autoloader/prism-autoloader.min.js" data-no-mirror></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/quicklink.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/anchor.min.js"></script>

<!-- Lunr search -->
@if (Context.GetBool(WebKeys.GenerateSearchIndex))
Expand Down Expand Up @@ -233,6 +234,9 @@

<!-- Scripts -->
<script>
// Should run before document.ready. See https://github.com/bryanbraun/anchorjs/issues/69#issuecomment-255503575
anchors.add('#content h1:not(.no-anchor), #content h2:not(.no-anchor), #content h3:not(.no-anchor), #content h4:not(.no-anchor)');

$(document).ready(function() {
quicklink.listen();

Expand Down
11 changes: 11 additions & 0 deletions input/assets/css/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,17 @@ code, code[class*="language-"], pre[class*="language-"] {
}
}

/* Anchors */

.anchorjs-link {
color: $gray-400;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My design capabilities are limited 😉 So feel free to improve the colors


&:hover {
color: $gray-400;
text-decoration: none;
}
}

/* Mermaid */
.mermaid {
overflow: hidden !important;
Expand Down