Skip to content

Commit d8ef553

Browse files
committed
feat: add View Markdown button to doc pages
Adds a ViewMarkdown component that renders a "View Markdown" link button next to "Edit this page" in the feedback section, surfacing the raw .md URL that the markdownSource middleware already serves.
1 parent 6b38737 commit d8ef553

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

_components/Feedback.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import EditThisPage from "./EditThisPage.tsx";
2+
import ViewMarkdown from "./ViewMarkdown.tsx";
23

34
export default function Feedback({ file }: { file: string | undefined }) {
45
if (!file) {
@@ -70,6 +71,7 @@ export default function Feedback({ file }: { file: string | undefined }) {
7071
</svg>
7172
</label>
7273
{!file.includes("[") && <EditThisPage file={file} />}
74+
{!file.includes("[") && <ViewMarkdown file={file} />}
7375
</div>
7476
<div
7577
id="feedback-more"

_components/ViewMarkdown.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export default function ViewMarkdown({ file }: { file: string | undefined }) {
2+
if (!file) return null;
3+
4+
return (
5+
<a class="btn" target="_blank" href={file}>
6+
View Markdown
7+
<svg
8+
xmlns="http://www.w3.org/2000/svg"
9+
aria-hidden="true"
10+
focusable="false"
11+
fill="currentColor"
12+
width="16"
13+
height="16"
14+
viewBox="0 0 16 16"
15+
style="display:inline-block;user-select:none;vertical-align:text-bottom;"
16+
>
17+
<path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z" />
18+
</svg>
19+
</a>
20+
);
21+
}

0 commit comments

Comments
 (0)