|
20 | 20 | </script> |
21 | 21 |
|
22 | 22 | <script lang="ts"> |
| 23 | + import { browser } from "$app/environment"; |
23 | 24 | import { |
24 | 25 | ArrowUpRight, |
25 | 26 | ChevronLeft, |
|
194 | 195 |
|
195 | 196 | return result; |
196 | 197 | } |
| 198 | +
|
| 199 | + /** |
| 200 | + * Returns the previous page to go back to |
| 201 | + */ |
| 202 | + function getPreviousPath() { |
| 203 | + if (!browser || !document.referrer) return "/"; |
| 204 | + return new URL(document.referrer).pathname; |
| 205 | + } |
197 | 206 | </script> |
198 | 207 |
|
199 | 208 | <h2 class="group mb-8 scroll-m-20 border-b pb-2 text-2xl font-semibold xs:text-3xl"> |
|
522 | 531 | </div> |
523 | 532 | <!-- Bottom links --> |
524 | 533 | <div class="mt-16 flex w-full flex-col-reverse justify-between gap-8 md:flex-row md:items-center"> |
525 | | - <Button href="/" variant="link" class="group mr-auto md:mr-0"> |
| 534 | + <Button href={getPreviousPath()} variant="link" class="group mr-auto md:mr-0"> |
526 | 535 | <ChevronLeft class="mr-1 size-4 transition-transform duration-300 group-hover:-translate-x-1" /> |
527 | | - Back to homepage |
| 536 | + Back |
| 537 | + {#if getPreviousPath() === "/"} |
| 538 | + to homepage |
| 539 | + {/if} |
528 | 540 | </Button> |
529 | 541 | <div class="flex flex-col-reverse items-end gap-4 md:flex-row md:items-center"> |
530 | | - <div class="flex flex-wrap justify-end gap-4"> |
531 | | - {#each linkedEntities as closingIssue (closingIssue.number)} |
532 | | - <Button |
533 | | - href="/{metadata.type === 'pull' |
534 | | - ? 'issues' |
535 | | - : 'pull'}/{metadata.org}/{metadata.repo}/{closingIssue.number}" |
536 | | - variant="secondary" |
537 | | - > |
538 | | - Open {metadata.type === "pull" ? "issue" : "pull request"} #{closingIssue.number} |
539 | | - </Button> |
540 | | - {/each} |
541 | | - </div> |
| 542 | + {#if linkedEntities.length > 0} |
| 543 | + <div class="flex flex-wrap justify-end gap-4"> |
| 544 | + {#each linkedEntities as closingIssue (closingIssue.number)} |
| 545 | + <Button |
| 546 | + href="/{metadata.type === 'pull' |
| 547 | + ? 'issues' |
| 548 | + : 'pull'}/{metadata.org}/{metadata.repo}/{closingIssue.number}" |
| 549 | + variant="secondary" |
| 550 | + > |
| 551 | + Open {metadata.type === "pull" ? "issue" : "pull request"} #{closingIssue.number} |
| 552 | + </Button> |
| 553 | + {/each} |
| 554 | + </div> |
| 555 | + {/if} |
542 | 556 | <Button href={info.html_url} target="_blank" class="group dark:text-black"> |
543 | | - Open {metadata.type === "pull" ? "pull request" : "issue"} on GitHub |
| 557 | + Open {metadata.type === "pull" |
| 558 | + ? "pull request" |
| 559 | + : metadata.type === "issue" |
| 560 | + ? "issue" |
| 561 | + : "discussion"} on GitHub |
544 | 562 | <ArrowUpRight |
545 | 563 | class="ml-2 size-4 transition-transform duration-300 group-hover:translate-x-1 group-hover:-translate-y-1" |
546 | 564 | /> |
|
0 commit comments