Skip to content

[Feature request] The pageData from usePageData should be tracked, but it is read-only #477

@laoergege

Description

@laoergege

Feature request

Description

/**
 * Empty page data to be used as the fallback value
 */
const pageDataEmpty = readonly({
  key: '',
  path: '',
  title: '',
  lang: '',
  frontmatter: {},
  excerpt: '',
  headers: [],
} as PageData) as PageData

/**
 * Global page data ref
 */
export const pageData: PageDataRef = ref(pageDataEmpty)

/**
 * Returns the ref of the data of current page
 */
export const usePageData = <
  T extends Record<any, any> = Record<never, never>
>(): PageDataRef<T> => pageData as PageDataRef<T>

The pageData is async load.
In my mind, the pageData should be tracked, which is only read.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions