Skip to content

Commit

Permalink
feat(load): set route property on matched elemetn
Browse files Browse the repository at this point in the history
  • Loading branch information
megheaiulian committed Jan 19, 2023
1 parent ede96bb commit 6b92649
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/load.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { html as htm } from 'haunted';
import { RuleRet } from './match';
import { RuleRet, BaseRoute } from './match';

const html: typeof htm = (arr, ...thru) =>
htm(
Expand Down Expand Up @@ -42,7 +42,7 @@ export const load =
pack: (params: Record<string, string | number>) => T,
tag: string | ((u: URL) => string) = tagFromPath
) =>
<P extends { match: RuleRet }>({ match }: P) => {
<P extends { match: RuleRet; route: BaseRoute }>({ match, route }: P) => {
const url = match.url;
const params = {
...match.result?.groups,
Expand All @@ -51,6 +51,7 @@ export const load =
return Promise.resolve(pack(params)).then(() =>
createElement(typeof tag === 'function' ? tag(url) : tag, {
params,
route,
})
);
};

0 comments on commit 6b92649

Please sign in to comment.