# Snippets. I setup this """guide""" because I'm prone to forgetting important things. :P [https://github.com/PierBover/prosemirror-cookbook](Prosemirror Cookbook) ### Use Hono Please, import `import Hono from '@/lib/hono';` instead of regular Hono! It works the same, but it's configured to work with (e.g) `c.get('user')` without annoying type checking errors. Also use zValidator from `'@/lib/zod'` instead of the usual zValidator, since it does not send the proper custom errors, and they're really ugly. ### Bundle typescript code Easy! Write code in `/src/client/{module-name}/index.ts` (`index.ts` being the entrypoint) and then it'll be available at `/bundles/{module-name}/index.js`. Then import with ```html ``` ### Include a tooltip. Goes inside an .eta template. ```html <% block("header", () => { %> <% }) %>
Hover me
I'm a tooltip!
``` ### Make a button red. ```html ``` ### Authentication middleware. Add the following import: `import { redirect_if_auth } from '@/middleware/redirect';` - To keep authenticated users out: `redirect_if_auth("(TARGET)", true)`; - To keep unauthenticated users out: `redirect_if_auth("(TARGET)", false)`; - To request authenticated user data: - Add the following import: `import { session_auth } from '@/middleware/authenticated';` - Use `app.use(session_auth);` ### Errors Whenever you want to tell the user something went wrong, redirect to any page and add ```ts return c.redirect(`/?error=${error.name}`); ``` to render it on their end with a nice message. ### Base64 encode and decode inside eta. ```eta <% utils.btoa(string-here) %> <% utils.atob(base64-here) %> ```