Skip to content

useCmsBlock

useCmsBlock ​

Composable to get cms block content

Types ​

ts
export function useCmsBlock<BLOCK_TYPE extends Schemas["CmsBlock"]>(
  content: MaybeRefOrGetter<BLOCK_TYPE>,
): UseCmsBlockReturn

source code

ts
export type UseCmsBlockReturn = {
  /**
   * Cms block content, as it was when the composable was called.
   */
  block: Schemas["CmsBlock"];
  /**
   * Get slot content by slot name (identifier).
   *
   * Reads the block on every call, so it follows a `ref` or getter passed as
   * `content`.
   *
   * A block does not have to carry every slot its layout allows: the lookup
   * returns `undefined` at runtime for a slot that is not there, which the
   * return type does not express yet. Guard on the result.
   * @example getSlotContent("main")
   */
  getSlotContent(slotName: string): ArrayElement<Schemas["CmsBlock"]["slots"]>;
};

source code

Was this page helpful?
UnsatisfiedSatisfied
Be the first to vote!
0.0 / 5  (0 votes)