useStatamicI18nParams

Gitlab
Composable for handling internationalized route parameters in Statamic.
Added since: v1.0.0
Last changed:
This composable will only be available when the following conditions are met:
  • The @nuxtjs/i18n module is installed and configured in your project.
  • The i18n option is enabled in the statamic module options.

Usage

useStatamicI18nParams is a composable that processes route slugs for different locales and sets up internationalized parameters for dynamic routes and catch-all routes.

It will setup the dynamic internationalized parameters for the route using the useSetI18nParams composable from the @nuxtjs/i18n module.

Basic example

app/pages/blogs/[...slug].vue
<script setup lang="ts">
const { 
data
,
error
} = await
useStatamicPage
();
useStatamicPageErrorHandler
(
error
);
useStatamicI18nParams(
data
.
value
?.
slugs
);
</script>

Advanced example

You can also pass a custom slugs object to the composable.

app/pages/blogs/[...slug].vue
<script setup lang="ts">
const { 
data
,
error
} = await
useStatamicPage
();
useStatamicPageErrorHandler
(
error
);
useStatamicI18nParams({
en
: "/en/blog",
fr
: "/fr/blog",
}); </script>

Type Definition

function 
useStatamicI18nParams
(
slugs
:
Record
<string, string>)

API Reference

Params

slugs
Record<string, string>
Record mapping locale codes to their corresponding slugs

Return Value

{ params: Record<string, string> }
The object containing the processed parameters for all locales.

It will also set the internationalized parameters for the route using the useSetI18nParams composable from the @nuxtjs/i18n module.

Changelog

v1.0.0

on

#407d36db

-

feat: released initial version of nuxt-statamic