Skip to content

Commit 42f4233

Browse files
authored
Merge pull request #1071 from DuendeSoftware/mb/experiments/contributors-list
Add contributors to sidebar
2 parents 2f62601 + 64cf930 commit 42f4233

9 files changed

Lines changed: 593 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
2022

2123
- name: Setup .NET
2224
uses: actions/setup-dotnet@v4
@@ -30,6 +32,8 @@ jobs:
3032

3133
- name: Build container
3234
run: dotnet build.cs container
33-
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
3438
- name: Run tests
3539
run: dotnet build.cs dotnet-test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ yarn-error.log*
1616
pnpm-debug.log*
1717

1818

19+
# generated build data
20+
astro/src/data/contributors.json
21+
1922
# environment variables
2023
.env
2124
.env.production

astro/astro.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { duendeOpenGraphImage } from "./src/plugins/duende-og-image.js";
1818
import removeMarkdownExtensions from "./src/plugins/remove-markdown-extensions.js";
1919
import staticRedirects from "./src/plugins/static-redirects.js";
2020
import markdownOutput from "./src/plugins/markdown-output.js";
21+
import contributorMapping from "./src/plugins/contributor-mapping.js";
2122

2223
// https://astro.build/config
2324
export default defineConfig({
@@ -35,6 +36,10 @@ export default defineConfig({
3536
},
3637
],
3738
integrations: [
39+
contributorMapping({
40+
include: ["src/content/docs/**"],
41+
repo: "DuendeSoftware/docs.duendesoftware.com",
42+
}),
3843
starlight({
3944
customCss: ["./src/styles/custom.css"],
4045
routeMiddleware: ["./src/plugins/search-topic-middleware.ts"],
@@ -188,6 +193,7 @@ export default defineConfig({
188193
Banner: "./src/components/Banner.astro",
189194
Head: "./src/components/Head.astro",
190195
Pagination: "./src/components/Pagination.astro",
196+
PageSidebar: "./src/components/PageSidebar.astro",
191197
},
192198
sidebar: [
193199
{
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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

Comments
 (0)