Documentation / @zerotal/core / index / MarkdownBuilder
Class: MarkdownBuilder
Defined in: helpers/response.ts:170
Builder returned by markdown() that enables optional layout chaining, e.g.
return markdown(content, { title }).withLayout(Layout, { title }).
Calling .withLayout() re-renders the markdown inside the provided layout
function, overwriting the plain markdown response already set by markdown().
Implements PromiseLike<void> following the same pattern as ResponseBuilder.
Implements
PromiseLike<void>
Constructors
Constructor
new MarkdownBuilder(
content,options?,status?):MarkdownBuilder
Defined in: helpers/response.ts:175
Parameters
content
string
options?
BunMarkdownOptions & object
status?
number = 200
Returns
MarkdownBuilder
Methods
withLayout()
withLayout<
P>(layoutFn,props):void
Defined in: helpers/response.ts:196
Re-render the markdown content inside a custom layout function.
layoutFn receives { ...props, content: <rendered-html> } and must return
a complete HTML string. This call REPLACES the plain markdown response
that was set when markdown() was first called.
Type Parameters
P
P extends object
Parameters
layoutFn
(props) => string
props
Omit<P, "content">
Returns
void
Example
import { Layout } from "./_layout";
export function GET() {
const title = "Welcome to Zerotal!";
return markdown(CONTENT, { title }).withLayout(Layout, { title });
}
then()
then<
TResult1,TResult2>(onfulfilled?,onrejected?):PromiseLike<TResult1|TResult2>
Defined in: helpers/response.ts:214
Attaches callbacks for the resolution and/or rejection of the Promise.
Type Parameters
TResult1
TResult1 = void
TResult2
TResult2 = never
Parameters
onfulfilled?
((value) => TResult1 | PromiseLike<TResult1>) | null
The callback to execute when the Promise is resolved.
onrejected?
((reason) => TResult2 | PromiseLike<TResult2>) | null
The callback to execute when the Promise is rejected.
Returns
PromiseLike<TResult1 | TResult2>
A Promise for the completion of which ever callback is executed.
Implementation of
PromiseLike.then