Skip to content

Commit 39e0a66

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
1 parent 3b04125 commit 39e0a66

2 files changed

Lines changed: 77 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: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
import MobileTableOfContents from 'virtual:starlight/components/MobileTableOfContents';
3+
import TableOfContents from 'virtual:starlight/components/TableOfContents';
4+
5+
const { slug } = Astro.locals.starlightRoute;
6+
const filePath = slug === '' ? 'src/content/docs/index.mdx' : `src/content/docs/${slug}.mdx`;
7+
const editUrl = `https://github.com/opensearch-project/observability-stack/edit/main/docs/starlight-docs/${filePath}`;
8+
const issueUrl = `https://github.com/opensearch-project/observability-stack/issues/new?title=Docs+feedback:+${encodeURIComponent(slug || 'index')}&labels=documentation`;
9+
---
10+
11+
{
12+
Astro.locals.starlightRoute.toc && (
13+
<>
14+
<div class="lg:sl-hidden">
15+
<MobileTableOfContents />
16+
</div>
17+
<div class="right-sidebar-panel sl-hidden lg:sl-block">
18+
<div class="sl-container">
19+
<TableOfContents />
20+
<div class="sidebar-links">
21+
<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>
22+
<a href={issueUrl} target="_blank" rel="noopener">💬 Report a docs issue</a>
23+
</div>
24+
</div>
25+
</div>
26+
</>
27+
)
28+
}
29+
30+
<style>
31+
@layer starlight.core {
32+
.right-sidebar-panel {
33+
padding: 1rem var(--sl-sidebar-pad-x);
34+
}
35+
.sl-container {
36+
width: calc(var(--sl-sidebar-width) - 2 * var(--sl-sidebar-pad-x));
37+
}
38+
.right-sidebar-panel :global(h2) {
39+
color: var(--sl-color-white);
40+
font-size: var(--sl-text-h5);
41+
font-weight: 600;
42+
line-height: var(--sl-line-height-headings);
43+
margin-bottom: 0.5rem;
44+
}
45+
.right-sidebar-panel :global(:where(a)) {
46+
display: block;
47+
font-size: var(--sl-text-xs);
48+
text-decoration: none;
49+
color: var(--sl-color-gray-3);
50+
overflow-wrap: anywhere;
51+
}
52+
.right-sidebar-panel :global(:where(a):hover) {
53+
color: var(--sl-color-white);
54+
}
55+
.sidebar-links {
56+
margin-top: 1.5rem;
57+
padding-top: 1rem;
58+
border-top: 1px solid var(--sl-color-gray-6);
59+
display: flex;
60+
flex-direction: column;
61+
gap: 0.5rem;
62+
}
63+
@media (min-width: 72rem) {
64+
.sl-container {
65+
max-width: calc(
66+
(
67+
(
68+
100vw - var(--sl-sidebar-width) - 2 * var(--sl-content-pad-x) - 2 *
69+
var(--sl-sidebar-pad-x)
70+
) * 0.25
71+
)
72+
);
73+
}
74+
}
75+
}
76+
</style>

0 commit comments

Comments
 (0)