useStatamicPageData

Gitlab
Access the current cached value of useStatamicPage.
Added since: v1.0.0
Last changed:

Usage

The useStatamicPageData composable is used to access the current cached value of useStatamicPage.

Basic example

app/pages/blogs/[...slug].vue
<script setup lang="ts">
const 
pageData
=
useStatamicPageData
();
</script>

Type Definition

function 
useStatamicPageData
<
T
extends
Record
<string, any> =
StatamicApiEntryDefaultFields
,
>(
options
: {
uri
?:
MaybeRefOrGetter
<string>;
params
?:
Partial
<
Omit
<
StatamicApiParamsUri
<
T
>, "uri">>;
fetchOptions
?:
Omit
<
FetchOptions
, "params">;
asyncDataOptions
?:
AsyncDataOptions
<
T
>;
} = {
params
: {},
fetchOptions
: {},
asyncDataOptions
: {},
}, ):
Ref
<
T
| undefined>

API Reference

Params

options.uri
MaybeRefOrGetter<string>
The Statamic page URI to retrieve the data for. Defaults to the current route’s URI if omitted.
options.params
Partial<Omit<StatamicApiParamsUri<T>, 'uri'>>
Additional parameters for fetching an entry by its URI path.
options.fetchOptions
Omit<FetchOptions, 'params'>
Options passed to the Statamic API fetch instance.
options.asyncDataOptions
AsyncDataOptions<T>
Options passed to the useAsyncData composable.

Return Value

Ref<DataT | undefined>
The cached data for the current Statamic page.

The data is retrieved from the cache using the useStatamicCacheKey and useNuxtData composables.

Changelog

v1.1.1

on

#71e233a1

-

fix: cacheKey for useStatamicPage is now less sensitve

v1.0.1

on

#95765ee3

-

improvement: `useStatamicPageData` cachekey now matches `useStatamicPage`

v1.0.0

on

#407d36db

-

feat: released initial version of nuxt-statamic