Saltar al contenido principal

Function: useAstroGetStaticPaths()

useAstroGetStaticPaths<TData, TParam, TProps>(getCollectionFn, collectionName, options?): Promise<AstroServiceResult<AstroPath<TParam, TProps>[]>>

Defined in: src/adapters/astro/astro.service.ts:71

Fetch a collection and transform it into safe Astro paths. Returns a result object instead of throwing on error.

Type Parameters

TData

TData = unknown

TParam

TParam extends string = "slug"

TProps

TProps = CollectionEntryLike<TData>

Parameters

getCollectionFn

(collection) => Promise<CollectionEntryLike<TData>[]>

Astro's getCollection function

collectionName

string

Name of the collection to fetch

options?

PathsOptions<CollectionEntryLike<TData>, TParam, TProps> = {}

Path generation options

Returns

Promise<AstroServiceResult<AstroPath<TParam, TProps>[]>>

Safe result with data or error

Example

export async function getStaticPaths() {
const result = await useAstroGetStaticPaths(getCollection, "blog");
if (result.ok) return result.data;
TODO: traer el useLogger('error', result.error)
console.error(result.error);
return [];
}