@studio-fes/layer-strapi 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @studio-fes/layer-strapi
2
2
 
3
+ ## 0.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - fix useStrapiSEO and useCraftSEO fallback image to have the baseUrl
8
+
9
+ ## 0.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - fix strapi media url resolution and update both craft and strapi seo to have a fallback png image
14
+
3
15
  ## 0.3.0
4
16
 
5
17
  ### Minor Changes
@@ -1,5 +1,12 @@
1
1
  import type { SeoMetaFragment } from '~/types/graphql-operations'
2
2
 
3
+ function getFallbackImage(): string | null {
4
+ const runtimeConfig = useRuntimeConfig()
5
+ const nuxtImage = useImage()
6
+ const baseUrl = (runtimeConfig.public.baseUrl as string).replace(/\/$/, '')
7
+ return nuxtImage(`${baseUrl}/${runtimeConfig.public.ogImageFallback}`, { width: 1200, height: 630, quality: 80 })
8
+ }
9
+
3
10
  export function useStrapiSEO(seoData?: MaybeRefOrGetter<SeoMetaFragment>) {
4
11
  const runtimeConfig = useRuntimeConfig()
5
12
  const nuxtImage = useImage()
@@ -10,13 +17,18 @@ export function useStrapiSEO(seoData?: MaybeRefOrGetter<SeoMetaFragment>) {
10
17
 
11
18
  const { metaTitle, metaDescription, metaImage, openGraph, metaRobots, keywords } = toValue(seoData)
12
19
 
20
+ const ogImageData = openGraph?.ogImage || metaImage
21
+ const ogImage = ogImageData?.url
22
+ ? nuxtImage(runtimeConfig.public.backendUrl + ogImageData.url, { width: 1200, height: 630, quality: 80 })
23
+ : getFallbackImage()
24
+
13
25
  useSeoMeta({
14
26
  title: metaTitle,
15
27
  description: metaDescription,
16
- ogImage: nuxtImage(runtimeConfig.public.imageDomain + (openGraph?.ogImage || metaImage)?.url, { width: 1200, height: 630, quality: 60 }),
28
+ ogImage,
17
29
  ogTitle: openGraph?.ogTitle || metaTitle,
18
30
  ogDescription: openGraph?.ogDescription || metaDescription,
19
- ogImageAlt: (openGraph?.ogImage || metaImage)?.alternativeText || metaTitle,
31
+ ogImageAlt: ogImageData?.alternativeText || metaTitle,
20
32
  twitterCard: 'summary_large_image',
21
33
  robots: metaRobots,
22
34
  keywords,
@@ -5,13 +5,13 @@ export function parseStrapiImage(image: StrapiFileFragment | undefined): NuxtImg
5
5
  if (!image)
6
6
  return null
7
7
 
8
- const runtimeConfig = useRuntimeConfig()
8
+ const config = useRuntimeConfig()
9
9
  const { width, height, url: src, alternativeText: alt } = image
10
10
 
11
11
  return {
12
12
  width,
13
13
  height,
14
- src: runtimeConfig.public.imageDomain + src,
14
+ src: `${config.public.backendUrl}${src}`,
15
15
  alt,
16
16
  } as {
17
17
  width: number
@@ -5,12 +5,12 @@ export function parseStrapiVideo(video: StrapiFileFragment | null | undefined):
5
5
  if (!video)
6
6
  return {}
7
7
 
8
- const runtimeConfig = useRuntimeConfig()
8
+ const config = useRuntimeConfig()
9
9
  const id = useId()
10
10
 
11
11
  return {
12
12
  id: `video-${id}`,
13
- src: runtimeConfig.public.imageDomain + video.url,
13
+ src: `${config.public.backendUrl}${video.url}`,
14
14
  width: video.width,
15
15
  height: video.height,
16
16
  }
package/nuxt.config.ts CHANGED
@@ -12,6 +12,9 @@ export default defineNuxtConfig({
12
12
 
13
13
  runtimeConfig: {
14
14
  multiCacheEnabled: import.meta.env.NUXT_CACHE_ENABLED === 'true',
15
+ public: {
16
+ backendUrl: '',
17
+ },
15
18
  },
16
19
 
17
20
  graphqlMiddleware: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@studio-fes/layer-strapi",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.3.2",
5
5
  "main": "./nuxt.config.ts",
6
6
  "dependencies": {
7
7
  "@nuxt/eslint": "latest",
@@ -15,7 +15,7 @@
15
15
  "nuxt": "^4.4.8",
16
16
  "typescript": "^6.0.3",
17
17
  "vue": "latest",
18
- "@studio-fes/layer-base": "0.3.0"
18
+ "@studio-fes/layer-base": "0.3.2"
19
19
  },
20
20
  "description": "Create Nuxt extendable layer with this GitHub template.",
21
21
  "repository": {