@studio-fes/layer-strapi 0.2.17 → 0.3.0

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.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Simplified env variables and fixed minor changes on components
8
+
9
+ ## 0.2.18
10
+
11
+ ### Patch Changes
12
+
13
+ - update dependencies, server folder and media components to edit props
14
+
3
15
  ## 0.2.17
4
16
 
5
17
  ### Patch Changes
@@ -7,10 +7,13 @@ export interface StrapiImageProps extends NuxtImgProps {
7
7
  }
8
8
 
9
9
  const props = defineProps<StrapiImageProps>()
10
- const imageProps = computed(() => ({
11
- ...reactiveOmit(props, 'image'),
12
- ...parseStrapiImage(props.image),
13
- }))
10
+ const imageProps = computed(() => {
11
+ const fromStrapi = parseStrapiImage(props.image)
12
+ const fromProps = Object.fromEntries(
13
+ Object.entries(reactiveOmit(props, 'image')).filter(([, v]) => v !== undefined),
14
+ )
15
+ return { ...fromStrapi, ...fromProps }
16
+ })
14
17
  </script>
15
18
 
16
19
  <template>
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import type { StrapiImageProps } from '@studio-fes/layer-strapi/app/components/StrapiImage.vue'
3
- import type { StrapiVideoProps } from '~/components/StrapiVideo.vue'
3
+ import type { StrapiVideoProps } from '@studio-fes/layer-strapi/app/components/StrapiVideo.vue'
4
4
  import type { StrapiFileFragment } from '~/types/graphql-operations'
5
5
 
6
6
  const props = defineProps<{
@@ -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>
@@ -8,11 +8,14 @@ export interface StrapiVideoProps extends VideoProps {
8
8
  }
9
9
 
10
10
  const props = defineProps<StrapiVideoProps>()
11
+ const videoProps = computed(() => {
12
+ const fromStrapi = parseStrapiVideo(props.video)
13
+ const fromProps = Object.fromEntries(
14
+ Object.entries(reactiveOmit(props, 'video')).filter(([, v]) => v !== undefined),
15
+ )
11
16
 
12
- const videoProps = computed(() => ({
13
- ...reactiveOmit(props, 'video'),
14
- ...parseStrapiVideo(props.video),
15
- }))
17
+ return { ...fromStrapi, ...fromProps }
18
+ })
16
19
  </script>
17
20
 
18
21
  <template>
@@ -1,4 +1,3 @@
1
- // import type { StrapiFileFragment } from '#graphql-operations'
2
1
  import type { NuxtImgProps } from '@studio-fes/layer-base/app/components/Image.vue'
3
2
  import type { StrapiFileFragment } from '~/types/graphql-operations'
4
3
 
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
 
@@ -13,11 +16,15 @@ export default defineNuxtConfig({
13
16
 
14
17
  graphqlMiddleware: {
15
18
  downloadSchema: false,
16
- graphqlEndpoint: 'https://example.com/graphql',
19
+ graphqlEndpoint,
17
20
  serverApiPrefix: '/gql',
18
21
  clientCache: {
19
22
  enabled: true,
20
23
  },
21
24
  autoImportPatterns: ['./queries/**/*.gql'],
22
25
  },
26
+
27
+ image: {
28
+ domains: [hostname],
29
+ },
23
30
  })
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@studio-fes/layer-strapi",
3
3
  "type": "module",
4
- "version": "0.2.17",
4
+ "version": "0.3.0",
5
5
  "main": "./nuxt.config.ts",
6
6
  "dependencies": {
7
7
  "@nuxt/eslint": "latest",
8
- "nuxt-graphql-middleware": "^5.3.2",
8
+ "nuxt-graphql-middleware": "^5.4.0",
9
9
  "nuxt-multi-cache": "^4.0.3",
10
10
  "vue-strapi-blocks-renderer": "1.1.1"
11
11
  },
12
12
  "devDependencies": {
13
- "@types/node": "^25.5.0",
14
- "eslint": "^10.0.3",
15
- "nuxt": "^4.4.2",
16
- "typescript": "^5.9.3",
13
+ "@types/node": "^25.9.3",
14
+ "eslint": "^10.5.0",
15
+ "nuxt": "^4.4.8",
16
+ "typescript": "^6.0.3",
17
17
  "vue": "latest",
18
- "@studio-fes/layer-base": "0.2.17"
18
+ "@studio-fes/layer-base": "0.3.0"
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
+ }
@@ -1,32 +0,0 @@
1
- import type { FetchResponse } from 'ofetch'
2
- import { defineGraphqlServerOptions } from 'nuxt-graphql-middleware/server-options'
3
-
4
- export default defineGraphqlServerOptions({
5
- async doGraphqlRequest(context) {
6
- const { operationName, variables, operationDocument } = context
7
-
8
- const config = useRuntimeConfig()
9
-
10
- function doRequest(): Promise<FetchResponse<{ data: any, errors: any[] }>> {
11
- return $fetch.raw(config.graphqlMiddleware.graphqlEndpoint, {
12
- method: 'POST',
13
- ignoreResponseError: true,
14
- body: {
15
- query: operationDocument,
16
- variables,
17
- operationName,
18
- }
19
- })
20
- }
21
-
22
- const res = await doRequest()
23
-
24
- return {
25
- data: res._data?.data,
26
- errors: res._data?.errors?.map(e => ({
27
- ...e,
28
- path: Array.isArray(e.path) ? e.path : [],
29
- })) || [],
30
- }
31
- },
32
- })
@@ -1,22 +0,0 @@
1
- /// <reference types="vite/client" />
2
-
3
- import { defineMultiCacheOptions } from 'nuxt-multi-cache/server-options'
4
- import fsDriver from 'unstorage/drivers/fs'
5
- import nullDriver from 'unstorage/drivers/null'
6
-
7
- export default defineMultiCacheOptions(() => {
8
- const config = useRuntimeConfig()
9
- const { multiCacheEnabled } = config
10
-
11
- const driver = multiCacheEnabled
12
- ? fsDriver({ base: '.nuxt-multi-cache' })
13
- : nullDriver()
14
-
15
- return {
16
- data: {
17
- storage: {
18
- driver,
19
- },
20
- },
21
- }
22
- })