@studio-fes/layer-strapi 0.2.18 → 0.3.1

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.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fix strapi media url resolution and update both craft and strapi seo to have a fallback png image
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Simplified env variables and fixed minor changes on components
14
+
3
15
  ## 0.2.18
4
16
 
5
17
  ### Patch Changes
@@ -14,12 +14,12 @@ const isImage = computed(() => mediaIsImage(props.media))
14
14
  </script>
15
15
 
16
16
  <template>
17
- <StrapiImage
17
+ <LazyStrapiImage
18
18
  v-if="isImage"
19
19
  v-bind="imgProps"
20
20
  :image="media"
21
21
  />
22
- <StrapiVideo
22
+ <LazyStrapiVideo
23
23
  v-else-if="isVideo"
24
24
  v-bind="videoProps"
25
25
  :video="media"
@@ -27,6 +27,10 @@ const isImage = computed(() => mediaIsImage(props.media))
27
27
  <template #default="{ progress, isPlaying }">
28
28
  <slot name="media-chrome" :progress :is-playing />
29
29
  </template>
30
- </StrapiVideo>
31
- <pre v-else>There is no format for you.</pre>
30
+ </LazyStrapiVideo>
31
+ <slot v-else name="empty">
32
+ <DevOnly>
33
+ There is no format for you.
34
+ </DevOnly>
35
+ </slot>
32
36
  </template>
@@ -1,5 +1,11 @@
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
+ return nuxtImage(`/${runtimeConfig.public.ogImageFallback}`, { width: 1200, height: 630, quality: 80 })
7
+ }
8
+
3
9
  export function useStrapiSEO(seoData?: MaybeRefOrGetter<SeoMetaFragment>) {
4
10
  const runtimeConfig = useRuntimeConfig()
5
11
  const nuxtImage = useImage()
@@ -10,13 +16,18 @@ export function useStrapiSEO(seoData?: MaybeRefOrGetter<SeoMetaFragment>) {
10
16
 
11
17
  const { metaTitle, metaDescription, metaImage, openGraph, metaRobots, keywords } = toValue(seoData)
12
18
 
19
+ const ogImageData = openGraph?.ogImage || metaImage
20
+ const ogImage = ogImageData?.url
21
+ ? nuxtImage(runtimeConfig.public.backendUrl + ogImageData.url, { width: 1200, height: 630, quality: 80 })
22
+ : getFallbackImage()
23
+
13
24
  useSeoMeta({
14
25
  title: metaTitle,
15
26
  description: metaDescription,
16
- ogImage: nuxtImage(runtimeConfig.public.imageDomain + (openGraph?.ogImage || metaImage)?.url, { width: 1200, height: 630, quality: 60 }),
27
+ ogImage,
17
28
  ogTitle: openGraph?.ogTitle || metaTitle,
18
29
  ogDescription: openGraph?.ogDescription || metaDescription,
19
- ogImageAlt: (openGraph?.ogImage || metaImage)?.alternativeText || metaTitle,
30
+ ogImageAlt: ogImageData?.alternativeText || metaTitle,
20
31
  twitterCard: 'summary_large_image',
21
32
  robots: metaRobots,
22
33
  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
@@ -1,4 +1,7 @@
1
- // https://nuxt.com/docs/api/configuration/nuxt-config
1
+ import { parseEnv } from './parse-env'
2
+
3
+ const { graphqlEndpoint, hostname } = parseEnv()
4
+
2
5
  export default defineNuxtConfig({
3
6
  extends: ['@studio-fes/layer-base'],
4
7
 
@@ -9,15 +12,22 @@ export default defineNuxtConfig({
9
12
 
10
13
  runtimeConfig: {
11
14
  multiCacheEnabled: import.meta.env.NUXT_CACHE_ENABLED === 'true',
15
+ public: {
16
+ backendUrl: '',
17
+ },
12
18
  },
13
19
 
14
20
  graphqlMiddleware: {
15
21
  downloadSchema: false,
16
- graphqlEndpoint: 'https://example.com/graphql',
22
+ graphqlEndpoint,
17
23
  serverApiPrefix: '/gql',
18
24
  clientCache: {
19
25
  enabled: true,
20
26
  },
21
27
  autoImportPatterns: ['./queries/**/*.gql'],
22
28
  },
29
+
30
+ image: {
31
+ domains: [hostname],
32
+ },
23
33
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@studio-fes/layer-strapi",
3
3
  "type": "module",
4
- "version": "0.2.18",
4
+ "version": "0.3.1",
5
5
  "main": "./nuxt.config.ts",
6
6
  "dependencies": {
7
7
  "@nuxt/eslint": "latest",
@@ -10,12 +10,12 @@
10
10
  "vue-strapi-blocks-renderer": "1.1.1"
11
11
  },
12
12
  "devDependencies": {
13
- "@types/node": "^25.6.0",
14
- "eslint": "^10.2.1",
15
- "nuxt": "^4.4.2",
13
+ "@types/node": "^25.9.3",
14
+ "eslint": "^10.5.0",
15
+ "nuxt": "^4.4.8",
16
16
  "typescript": "^6.0.3",
17
17
  "vue": "latest",
18
- "@studio-fes/layer-base": "0.2.18"
18
+ "@studio-fes/layer-base": "0.3.1"
19
19
  },
20
20
  "description": "Create Nuxt extendable layer with this GitHub template.",
21
21
  "repository": {
package/parse-env.ts ADDED
@@ -0,0 +1,23 @@
1
+ export function parseEnv() {
2
+ const backendUrl = import.meta.env.NUXT_PUBLIC_BACKEND_URL
3
+ if (!backendUrl) {
4
+ throw new Error('NUXT_PUBLIC_BACKEND_URL environment variable is not set')
5
+ }
6
+
7
+ let graphqlEndpoint: string
8
+ let hostname: string
9
+ try {
10
+ const baseUrl = new URL(backendUrl)
11
+ hostname = baseUrl.hostname
12
+ if (!hostname) {
13
+ throw new Error('Missing hostname in NUXT_PUBLIC_BACKEND_URL environment variable')
14
+ }
15
+ graphqlEndpoint = new URL('graphql', baseUrl).toString()
16
+ }
17
+
18
+ catch {
19
+ throw new Error('Invalid NUXT_PUBLIC_BACKEND_URL environment variable')
20
+ }
21
+
22
+ return { graphqlEndpoint, hostname }
23
+ }