|
| 1 | +--- |
| 2 | +import { Icon } from '@astrojs/starlight/components'; |
| 3 | +import MobileTableOfContents from 'virtual:starlight/components/MobileTableOfContents'; |
| 4 | +import TableOfContents from 'virtual:starlight/components/TableOfContents'; |
| 5 | +import contributorsData from '../data/contributors.json'; |
| 6 | +
|
| 7 | +const { editUrl, toc } = Astro.locals.starlightRoute; |
| 8 | +const filePath = Astro.locals.starlightRoute.entry.filePath; |
| 9 | +
|
| 10 | +// Look up contributors for this page's source file |
| 11 | +const contributors = filePath ? (contributorsData as Record<string, { username: string; avatarUrl: string; profileUrl: string }[]>)[filePath] ?? [] : []; |
| 12 | +--- |
| 13 | + |
| 14 | +{toc && ( |
| 15 | + <> |
| 16 | + <div class="lg:sl-hidden"> |
| 17 | + <MobileTableOfContents /> |
| 18 | + </div> |
| 19 | + <div class="right-sidebar-panel sl-hidden lg:sl-block"> |
| 20 | + <div class="sl-container"> |
| 21 | + <TableOfContents /> |
| 22 | + |
| 23 | + <div class="sidebar-meta"> |
| 24 | + {contributors.length > 0 && ( |
| 25 | + <div class="meta-section"> |
| 26 | + <h2>Page Contributors</h2> |
| 27 | + <div class="contributor-avatars"> |
| 28 | + {contributors.map((c) => ( |
| 29 | + <a href={c.profileUrl} title={c.username} target="_blank" rel="noopener noreferrer"> |
| 30 | + <img |
| 31 | + src={c.avatarUrl} |
| 32 | + alt={c.username} |
| 33 | + width="24" |
| 34 | + height="24" |
| 35 | + loading="lazy" |
| 36 | + decoding="async" |
| 37 | + /> |
| 38 | + </a> |
| 39 | + ))} |
| 40 | + </div> |
| 41 | + </div> |
| 42 | + )} |
| 43 | + |
| 44 | + {editUrl && ( |
| 45 | + <div class="meta-section"> |
| 46 | + <a href={editUrl} class="edit-link sl-flex print:hidden" target="_blank" rel="noopener noreferrer"> |
| 47 | + <Icon name="pencil" size="1.2em" /> |
| 48 | + {Astro.locals.t('page.editLink')} |
| 49 | + </a> |
| 50 | + </div> |
| 51 | + )} |
| 52 | + </div> |
| 53 | + </div> |
| 54 | + </div> |
| 55 | + </> |
| 56 | +)} |
| 57 | + |
| 58 | +<style> |
| 59 | + @layer starlight.core { |
| 60 | + .right-sidebar-panel { |
| 61 | + padding: 1rem var(--sl-sidebar-pad-x); |
| 62 | + } |
| 63 | + .sl-container { |
| 64 | + width: calc(var(--sl-sidebar-width) - 2 * var(--sl-sidebar-pad-x)); |
| 65 | + } |
| 66 | + .right-sidebar-panel :global(h2) { |
| 67 | + color: var(--sl-color-white); |
| 68 | + font-size: var(--sl-text-h5); |
| 69 | + font-weight: 600; |
| 70 | + line-height: var(--sl-line-height-headings); |
| 71 | + margin-bottom: 0.5rem; |
| 72 | + } |
| 73 | + .right-sidebar-panel :global(:where(a)) { |
| 74 | + display: block; |
| 75 | + font-size: var(--sl-text-xs); |
| 76 | + text-decoration: none; |
| 77 | + color: var(--sl-color-gray-3); |
| 78 | + overflow-wrap: anywhere; |
| 79 | + } |
| 80 | + .right-sidebar-panel :global(:where(a):hover) { |
| 81 | + color: var(--sl-color-white); |
| 82 | + } |
| 83 | + @media (min-width: 72rem) { |
| 84 | + .sl-container { |
| 85 | + max-width: calc( |
| 86 | + ( |
| 87 | + ( |
| 88 | + 100vw - var(--sl-sidebar-width) - 2 * var(--sl-content-pad-x) - 2 * |
| 89 | + var(--sl-sidebar-pad-x) |
| 90 | + ) * 0.25 |
| 91 | + ) |
| 92 | + ); |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + .sidebar-meta { |
| 98 | + margin-top: 2rem; |
| 99 | + padding-top: 1.5rem; |
| 100 | + border-top: 1px solid var(--sl-color-gray-6); |
| 101 | + display: flex; |
| 102 | + flex-direction: column; |
| 103 | + align-items: flex-start; |
| 104 | + gap: 1rem; |
| 105 | + } |
| 106 | + |
| 107 | + .meta-section { |
| 108 | + display: flex; |
| 109 | + flex-direction: column; |
| 110 | + align-items: flex-start; |
| 111 | + } |
| 112 | + |
| 113 | + .meta-section h2 { |
| 114 | + margin-bottom: 0.25rem !important; |
| 115 | + } |
| 116 | + |
| 117 | + .contributor-avatars { |
| 118 | + display: flex; |
| 119 | + flex-wrap: wrap; |
| 120 | + gap: 0.25rem; |
| 121 | + align-items: flex-start; |
| 122 | + } |
| 123 | + |
| 124 | + .contributor-avatars a { |
| 125 | + display: inline-flex; |
| 126 | + line-height: 0; |
| 127 | + } |
| 128 | + |
| 129 | + .contributor-avatars img { |
| 130 | + border-radius: 50%; |
| 131 | + } |
| 132 | + |
| 133 | + .edit-link { |
| 134 | + gap: 0.5rem; |
| 135 | + align-items: center; |
| 136 | + font-size: var(--sl-text-xs); |
| 137 | + color: var(--sl-color-gray-3); |
| 138 | + text-decoration: none; |
| 139 | + } |
| 140 | + |
| 141 | + .edit-link:hover { |
| 142 | + color: var(--sl-color-white); |
| 143 | + } |
| 144 | +</style> |
0 commit comments