Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ This project tries to follow [SemVer 2.0.0](https://semver.org/).
- Fixed links to open in new tab via `target="_blank"` instead of the invalid
value `target="about:blank"`. (#17)

- Fixed compiler links in episode info not updating when switching episode. (#19)

- Fixed issue where `Ctrl` + left mouse button clicking a link did not open the
link in a new tab. (#20)

Expand Down
28 changes: 18 additions & 10 deletions src/Link.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@

import { addWindowEventListener } from "./libs/util";

export let link: LinkOrHref = null;
export let href: string = linkHref(link);
export let target: string = href.startsWith("?") ? undefined : "_blank";
export let href: LinkOrHref = null;
export let target: string = null;
export let download: boolean | undefined = undefined;

$: label = linkLabel(link) ?? href;
$: actualHref = linkHref(href);
$: actualLabel = linkLabel(href) ?? actualHref;
$: actualTarget =
target ??
(!actualHref || actualHref.startsWith("?") ? undefined : "_blank");

let search = window.location.search;
$: isCurrent = href.startsWith("?") && search === href;
$: isCurrent =
actualHref && actualHref.startsWith("?") && search === actualHref;

function onclick(e: MouseEvent) {
if (!e.ctrlKey && href.startsWith("?") && window.history?.pushState) {
if (!e.ctrlKey && actualHref.startsWith("?") && window.history?.pushState) {
e.preventDefault();
window.history.pushState(null, href, href);
window.history.pushState(null, actualHref, actualHref);
window.dispatchEvent(new PopStateEvent("onpushstate", { state: null }));
}
}
Expand All @@ -31,9 +35,13 @@
<svelte:window on:popstate={onstatechanged} />

{#if isCurrent}
<span class="selected"><slot>{label}</slot></span>
<span class="selected"><slot>{actualLabel}</slot></span>
{:else}
<a {href} {target} {download} on:click={onclick} referrerpolicy="no-referrer"
><slot>{label}</slot></a
<a
href={actualHref}
target={actualTarget}
{download}
referrerpolicy="no-referrer"
on:click={onclick}><slot>{actualLabel}</slot></a
>
{/if}
6 changes: 3 additions & 3 deletions src/sections/EpisodeSection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
</p>
<p>
{#if currentEpisode.compilerLinks.length === 1}
Compiler link: <Link link={currentEpisode.compilerLinks[0]} />
Compiler link: <Link href={currentEpisode.compilerLinks[0]} />
{:else}
Compiler links:
<ul>
{#each currentEpisode.compilerLinks as link}
<li><Link {link} /></li>
{#each currentEpisode.compilerLinks as href}
<li><Link {href} /></li>
{/each}
</ul>
{/if}
Expand Down