Skip to content

Commit

Permalink
fix: fix markdown page link redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Je committed Oct 14, 2020
1 parent 487c2c0 commit 0b1ab39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions aleph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ export function ALEPH({ initial }: {
export async function redirect(url: string, replace?: boolean) {
const { location, history } = window as any

if (!util.isNEString(url)) {
return
}

if (util.isHttpUrl(url)) {
location.href = url
return
Expand Down
7 changes: 4 additions & 3 deletions project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,13 @@ export class Project {
` const appLinks = [];`,
` const onClick = e => {`,
` e.preventDefault();`,
` redirect(e.target.getAttribute("href"));`,
` redirect(e.currentTarget.getAttribute("href"));`,
` };`,
` if (ref.current) {`,
` ref.current.querySelectorAll("a").forEach(a => {`,
` if (!/^(https?|mailto|file):/i.test(a.getAttribute("href"))) {`,
` a.addEventListener("click", onClick);`,
` const href = a.getAttribute("href")`,
` if (href && !/^(https?|mailto|file):/i.test(href)) {`,
` a.addEventListener("click", onClick, false);`,
` appLinks.push(a);`,
` }`,
` });`,
Expand Down

0 comments on commit 0b1ab39

Please sign in to comment.