@thepassle/app-tools 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thepassle/app-tools",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {
package/router/README.md CHANGED
@@ -213,14 +213,18 @@ App:
213
213
  import { LitElement } from 'lit';
214
214
 
215
215
  class MyEl extends LitElement {
216
+ static properties = {
217
+ route: {}
218
+ }
219
+
216
220
  firstUpdated() {
217
221
  router.addEventListener('route-changed', () => {
218
- this.requestUpdate();
222
+ this.route = router.render();
219
223
  });
220
224
  }
221
225
 
222
226
  render() {
223
- return router.render();
227
+ return this.route;
224
228
  }
225
229
  }
226
230
  ```
@@ -301,6 +305,13 @@ const router = new Router({
301
305
  redirect('/404'),
302
306
  ],
303
307
  },
308
+ {
309
+ path: '/legacy/detail/:product',
310
+ title: 'Foo',
311
+ plugins: [
312
+ redirect(context => '/detail/${context.params.product}'),
313
+ ],
314
+ },
304
315
  ]
305
316
  });
306
317
  ```
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @param {string} path
2
+ * @param {string|((context:(import('../index.js').Context) => string)} path
3
3
  * @returns {import('../index.js').Plugin}
4
4
  */
5
5
  export function redirect(path) {
6
6
  return {
7
7
  name: 'redirect',
8
- shouldNavigate: () => ({
8
+ shouldNavigate: (context) => ({
9
9
  condition: () => false,
10
- redirect: path
10
+ redirect: typeof path === 'function' ? path(context) : path
11
11
  })
12
12
  }
13
- }
13
+ }