Skip to content

Commit

Permalink
Add edit link
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechu10 committed Oct 19, 2024
1 parent 8b6036e commit 2e3294a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/pages/book.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,24 @@ fn BookBody(section: String, #[prop(!optional)] doc: Option<String>) -> View {
.unwrap_or("Title Missing".to_string()),
};

let github_edit_link = match doc {
Some(doc) => format!("https://github.com/sycamore-rs/sycamore/edit/main/docs/next/{section}/{doc}.md"),
None => format!("https://github.com/sycamore-rs/sycamore/edit/main/docs/next/{section}.md"),
};

view! {
ServerTitle(title=title)
div(class="flex flex-row gap-4 w-full justify-center") {
BookSidebar {}
div(class="grow-0 min-w-0 px-2 pt-5 pb-10 prose prose-gray md:w-[80ch] prose-headings:scroll-mt-12") {
mdsycx::MDSycX(body=parsed.body)

div(class="mt-6 mr-2 text-right") {
a(class="text-sm", href=github_edit_link) {
i(class="bi bi-pencil mr-2")
"Edit this page on GitHub"
}
}
}
HeadingsOutline(headings=parsed.headings)
}
Expand Down

0 comments on commit 2e3294a

Please sign in to comment.