Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@yukukotani
Copy link
Contributor

@yukukotani yukukotani commented Nov 1, 2023

Every handler except LayoutHandler can receive Context as a parameter. This PR allow LayoutHandler to access Context as well.

I know that I'm hasty and need more discussion. I just want to show you what I want by code!

Background

I'm working on kuma-ui/kuma-ui#364. I'd like to use Context as a request-scoped dictionary in LayoutHandler to provide elegant API.

Rough example:

const handler: LayoutHandler = ({ children, head, c }) => {
  return (
    <KumaRegistry context={c}>
      <html lang="en">
        <head>
          {head.createTags()}
          <KumaHead context={c} />
        </head>
        <body>...</body>
      </html>
    </KumaRegistry>
  );
}


export type AppRoute<E extends Env = Env> = (app: Hono<E>) => void

export type LayoutContext = Omit<Context | 'render', 'setRenderer'>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would lead unexpected behavior to override the rendering in layouts, so omitting them here.

@yusukebe
Copy link
Collaborator

@yukukotani

Sorry for to be late. LGTM!

@yusukebe yusukebe merged commit 45ae97c into sonikjs:main Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants