waibu 1.1.17 → 1.1.18

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.
@@ -1,11 +1,14 @@
1
1
  async function buildHomesMenu (req) {
2
+ const { callHandler } = this.app.bajo
2
3
  const { get, find, orderBy } = this.lib._
3
4
  const routes = []
4
5
  for (const ns of this.app.bajo.pluginNames) {
5
- const href = get(this, `app.${ns}.config.waibuMpa.home`)
6
- if (!href) continue
7
- const item = { href, ns, title: get(this, `app.${ns}.config.waibu.title`, this.app[ns].title) }
8
- if (!find(routes, { href })) routes.push(item)
6
+ let home = get(this, `app.${ns}.config.waibuMpa.home`)
7
+ const homeHandler = get(this, `app.${ns}.config.waibuMpa.homeHandler`)
8
+ if (homeHandler) home = await callHandler(homeHandler)
9
+ if (!home) continue
10
+ const item = { href: home, ns, title: get(this, `app.${ns}.config.waibu.title`, this.app[ns].title) }
11
+ if (!find(routes, { href: home })) routes.push(item)
9
12
  }
10
13
  return orderBy(routes, ['title'])
11
14
  }
package/lib/home.js CHANGED
@@ -1,9 +1,10 @@
1
1
  async function home () {
2
- const { defaultsDeep } = this.app.bajo
2
+ const { defaultsDeep, callHandler } = this.app.bajo
3
3
  const { isString, pick } = this.lib._
4
4
  const config = this.getConfig()
5
5
  if (config.home) {
6
6
  if (isString(config.home)) config.home = { path: config.home }
7
+ if (config.home.pathHandler) config.home.path = await callHandler(config.home.pathHandler)
7
8
  await this.instance.get('/', async function (req, reply) {
8
9
  if (!config.home.forward) return reply.redirectTo(config.home.path)
9
10
  const opts = defaultsDeep(pick(req, ['params', 'query']), pick(config.home, ['params', 'query']))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "waibu",
3
- "version": "1.1.17",
3
+ "version": "1.1.18",
4
4
  "description": "Web Framework for Bajo",
5
5
  "main": "index.js",
6
6
  "scripts": {