Skip to content

Commit 53e8a85

Browse files
committed
docs: add Edit on GitHub and Report issue links to page sidebar
- Custom PageSidebar component with GitHub edit and issue creation links - Links appear below TOC on every page - Edit link resolves to correct file path on GitHub - Issue link pre-fills title and documentation label Signed-off-by: Kyle Hounslow <kylhouns@amazon.com>
1 parent f0e335c commit 53e8a85

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

docs/starlight-docs/astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default defineConfig({
2525
social: [{ icon: 'github', label: 'GitHub', href: 'https://github.com/opensearch-project/observability-stack' }],
2626
components: {
2727
Header: './src/components/CustomHeader.astro',
28+
PageSidebar: './src/components/PageSidebar.astro',
2829
},
2930
sidebar: [
3031
{
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
import MobileTableOfContents from 'virtual:starlight/components/MobileTableOfContents';
3+
import TableOfContents from 'virtual:starlight/components/TableOfContents';
4+
5+
const { slug, editUrl: starlightEditUrl } = Astro.locals.starlightRoute;
6+
const editUrl = starlightEditUrl?.href || `https://github.com/opensearch-project/observability-stack/edit/main/docs/starlight-docs/src/content/docs/${slug || 'index'}.mdx`;
7+
const issueUrl = `https://github.com/opensearch-project/observability-stack/issues/new?title=Docs+feedback:+${encodeURIComponent(slug || 'index')}&labels=documentation`;
8+
---
9+
10+
{
11+
Astro.locals.starlightRoute.toc && (
12+
<>
13+
<div class="lg:sl-hidden">
14+
<MobileTableOfContents />
15+
</div>
16+
<div class="right-sidebar-panel sl-hidden lg:sl-block">
17+
<div class="sl-container">
18+
<TableOfContents />
19+
<div class="sidebar-links">
20+
<a href={editUrl} target="_blank" rel="noopener"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" style="vertical-align: -2px; margin-right: 4px;"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>Edit this page on GitHub</a>
21+
<a href={issueUrl} target="_blank" rel="noopener">💬 Report a docs issue</a>
22+
</div>
23+
</div>
24+
</div>
25+
</>
26+
)
27+
}
28+
29+
<style>
30+
@layer starlight.core {
31+
.right-sidebar-panel {
32+
padding: 1rem var(--sl-sidebar-pad-x);
33+
}
34+
.sl-container {
35+
width: calc(var(--sl-sidebar-width) - 2 * var(--sl-sidebar-pad-x));
36+
}
37+
.right-sidebar-panel :global(h2) {
38+
color: var(--sl-color-white);
39+
font-size: var(--sl-text-h5);
40+
font-weight: 600;
41+
line-height: var(--sl-line-height-headings);
42+
margin-bottom: 0.5rem;
43+
}
44+
.right-sidebar-panel :global(:where(a)) {
45+
display: block;
46+
font-size: var(--sl-text-xs);
47+
text-decoration: none;
48+
color: var(--sl-color-gray-3);
49+
overflow-wrap: anywhere;
50+
}
51+
.right-sidebar-panel :global(:where(a):hover) {
52+
color: var(--sl-color-white);
53+
}
54+
.sidebar-links {
55+
margin-top: 1.5rem;
56+
padding-top: 1rem;
57+
border-top: 1px solid var(--sl-color-gray-6);
58+
display: flex;
59+
flex-direction: column;
60+
gap: 0.5rem;
61+
}
62+
@media (min-width: 72rem) {
63+
.sl-container {
64+
max-width: calc(
65+
(
66+
(
67+
100vw - var(--sl-sidebar-width) - 2 * var(--sl-content-pad-x) - 2 *
68+
var(--sl-sidebar-pad-x)
69+
) * 0.25
70+
)
71+
);
72+
}
73+
}
74+
}
75+
</style>

0 commit comments

Comments
 (0)