move app logic into templates (#444)

This commit is contained in:
Rich Harris
2018-09-30 10:30:00 -04:00
parent ff24877d8f
commit e30842caa8
19 changed files with 661 additions and 618 deletions

View File

@@ -0,0 +1,10 @@
import { select_route, prefetching, set_prefetching, prepare_page } from '../app';
import { Target } from '../types';
export default function prefetch(href: string) {
const target: Target = select_route(new URL(href, document.baseURI));
if (target && (!prefetching || href !== prefetching.href)) {
set_prefetching(href, prepare_page(target));
}
}