Skip to content

Commit

Permalink
Show anchor links on headings
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Jan 27, 2023
1 parent 15c8841 commit f951a77
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
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
6 changes: 5 additions & 1 deletion input/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
<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 -->
<!-- Lunr search -->c:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-sandbox\workbench\workbench.html
@if (Context.GetBool(WebKeys.GenerateSearchIndex))
{
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lunr.min.js"></script>
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;

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

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

0 comments on commit f951a77

Please sign in to comment.