Samuelreichoer
Samuelreichoer
NNuxt
Created by Samuelreichoer on 4/29/2025 in #❓・help
vitest not working with imports form '#app'
@kapa.ai How can I provide values in a vitest to mock module options?
8 replies
NNuxt
Created by Samuelreichoer on 3/25/2025 in #❓・help
Custom Fetch Types not align
This was the solution: import { defu } from 'defu' import type { UseFetchOptions } from '#app' export function useCraftFetch<T>( url: string | (() => string), options?: UseFetchOptions<T>, ) { const { authToken } = useRuntimeConfig().public.craftcms const defaults: UseFetchOptions<T> = { headers: { Authorization: authToken, }, } const params = defu(options, defaults) return useFetch(url, params) }
23 replies
NNuxt
Created by Samuelreichoer on 3/25/2025 in #❓・help
Custom Fetch Types not align
@kapa.ai Now I get folliwing ts error Argument of type 'string | Request | Ref<string | Request, string | Request> | (() => string | Request)' is not assignable to parameter of type 'NitroFetchRequest'. Type 'Ref<string | Request, string | Request>' is not assignable to type 'NitroFetchRequest'.ts(2345) in that line on url () => $fetch<T>(url, {
23 replies
NNuxt
Created by Samuelreichoer on 3/25/2025 in #❓・help
Custom Fetch Types not align
@kapa.ai Is it simpler to use useAsyndata in the custom fetch wrapper?
23 replies
NNuxt
Created by Samuelreichoer on 4/1/2025 in #❓・help
Hide secret token in plugin install options
@kapa.ai How does storyblok or other cms sdks manage this?
20 replies
NNuxt
Created by Samuelreichoer on 4/1/2025 in #❓・help
Hide secret token in plugin install options
@kapa.ai That's not a good dx, I loose all the ts support and I also need this token on client side requests
20 replies
NNuxt
Created by Samuelreichoer on 4/1/2025 in #❓・help
Hide secret token in plugin install options
@kapa.ai I mean how do I do it with a custom plugin that I maintain craftcms: { baseUrl: process.env.NUXT_PRIMARY_SITE_URL, authToken: 'Bearer iIkWn1cMYA181On591yqdhJluAzI-r1c', debug: false,
20 replies
NNuxt
Created by Samuelreichoer on 3/25/2025 in #❓・help
Custom Fetch Types not align
@kapa.ai Same error on all possible solutions.
23 replies
NNuxt
Created by Samuelreichoer on 3/25/2025 in #❓・help
Custom Fetch Types not align
Same error on all possible solutions.
23 replies
NNuxt
Created by Samuelreichoer on 3/2/2025 in #❓・help
runWithContext not working as expected
@kapa.ai When I return it like that return { title: computed(() => seoMaticData.value?.title), metaTags: computed(() => seoMaticData.value?.metaTags), linkTags: computed(() => seoMaticData.value?.linkTags), jsonLd: computed(() => seoMaticData.value?.jsonLd), } and import it like that const { metaTags, title, linkTags, jsonLd} = await useCraftSeoMatic() I get an ts error that Vue: Property metaTags does not exist on type { title: ComputedRef<string | undefined>; metaTags: ComputedRef<Record<string, any>[] | undefined>; linkTags: ComputedRef<Record<string, any>[] | undefined>; jsonLd: ComputedRef<...>; } | undefined
16 replies
NNuxt
Created by Samuelreichoer on 3/2/2025 in #❓・help
runWithContext not working as expected
When I return it like that return { title: computed(() => seoMaticData.value?.title), metaTags: computed(() => seoMaticData.value?.metaTags), linkTags: computed(() => seoMaticData.value?.linkTags), jsonLd: computed(() => seoMaticData.value?.jsonLd), } and import it like that const { metaTags, title, linkTags, jsonLd} = await useCraftSeoMatic() I get an ts error that Vue: Property metaTags does not exist on type { title: ComputedRef<string | undefined>; metaTags: ComputedRef<Record<string, any>[] | undefined>; linkTags: ComputedRef<Record<string, any>[] | undefined>; jsonLd: ComputedRef<...>; } | undefined
16 replies
NNuxt
Created by Samuelreichoer on 3/2/2025 in #❓・help
runWithContext not working as expected
@kapa.ai Alright so I use this useFetch and want to return all of these properties without loosing reacitvity const { data: seoMaticData, error } = await useFetch(apiEndpoint, { transform: (seoMaticData: SeoData) => { if (!seoMaticData || typeof seoMaticData !== 'object') { console.error('Transformation of SEOmatic data failed, please verify that the SEOmatic endpoint is working correctly') return undefined } return { title: seoMaticData.MetaTitleContainer?.title?.title ?? '', metaTags: generateMetaTags(seoMaticData.MetaTagContainer), linkTags: generateLinkTags(seoMaticData.MetaLinkContainer), jsonLd: seoMaticData.MetaJsonLdContainer ?? {}, }; }, }) how do I do this?
16 replies
NNuxt
Created by Samuelreichoer on 3/1/2025 in #❓・help
Prerendering not working
@kapa.ai Transform failed with 1 error: /Users/samuel/Documents/Private-Projekte/00-repos/nuxt-craftcms/src/runtime/composables/useComposables.ts:13:2: ERROR: Unexpected "const" the error happens at the getFullUrl var
103 replies
NNuxt
Created by Samuelreichoer on 3/1/2025 in #❓・help
Prerendering not working
@kapa.ai the code you provided does have a syntax error
103 replies
NNuxt
Created by Samuelreichoer on 3/1/2025 in #❓・help
Prerendering not working
@kapa.ai can i somehow check if i am in prerendering and use another method to determine the url?
103 replies
NNuxt
Created by Samuelreichoer on 3/1/2025 in #❓・help
Prerendering not working
@kapa.ai Nein nitro läuft auf local host somit ist dieses composable export function useCraftFullUrl() { const route = useRoute() const fullUrl = ref(import.meta.server ? useRequestURL().href : window.location.href) watch(route, () => { fullUrl.value = import.meta.server ? useRequestURL().href : window.location.href }) return fullUrl } falsch und kann nicht den richtigen url herausfinden und dann nicht den richtigen query bauen
103 replies
NNuxt
Created by Samuelreichoer on 3/1/2025 in #❓・help
Prerendering not working
Nein nitro läuft auf local host somit ist dieses composable export function useCraftFullUrl() { const route = useRoute() const fullUrl = ref(import.meta.server ? useRequestURL().href : window.location.href) watch(route, () => { fullUrl.value = import.meta.server ? useRequestURL().href : window.location.href }) return fullUrl } falsch und kann nicht den richtigen url herausfinden und dann nicht den richtigen query bauen
103 replies
NNuxt
Created by Samuelreichoer on 3/1/2025 in #❓・help
Prerendering not working
@kapa.ai Okey ich habe jetzt den fehler gefunden, der nitro host ist localhost und nicht wie gewünscht 'https://craft-nuxt-starter.ddev.site/' wie stelle ich das um?
103 replies
NNuxt
Created by Samuelreichoer on 3/1/2025 in #❓・help
Prerendering not working
Okey ich habe jetzt den fehler gefunden, der nitro host ist localhost und nicht wie gewünscht 'https://craft-nuxt-starter.ddev.site' wie stelle ich das um?
103 replies
NNuxt
Created by Samuelreichoer on 3/1/2025 in #❓・help
Prerendering not working
@kapa.ai that's the code of useCraftQuery import type { ElementType } from 'js-craftcms-api' import { useCraftUrlBuilder } from 'vue-craftcms' import { useAsyncData } from '#imports' function fetchFn(url: string) { return useAsyncData(craftcms:${url}, () => $fetch(url)) } export function useCraftQuery<T extends ElementType>(elementType: T) { const queryBuilder = useCraftUrlBuilder(elementType) return { ...queryBuilder, one() { const url = queryBuilder.buildUrl('one') return fetchFn(url) }, all() { const url = queryBuilder.buildUrl('all') return fetchFn(url) }, } }
103 replies