Single
Explore posts from serversToggle useAsyncData's server option on SSG with SSR dynamically.
@kapa.ai i am trying to do it like this but refresh seems not to load it from the remote but from the cache?
<script lang="ts" setup>
import { get } from '@vueuse/core'
import { useRouteQuery } from '@vueuse/router'
import { type News } from '~/types/directus/news'
const { data: news, refresh } = useAsyncData<News[]>('news', async () => {
return await useDirectus().getItems<News[]>('news', useDirectus().getLocaleFilter())
})
onMounted(() => {
if (get(useRouteQuery('ssr')) === 'false') {
refresh()
}
})
</script>
<template>
<div class="flex flex-col gap-y-24 justify-center items-center container">
<Welcome :title="$t('news.title')" :subTitle="$t('news.description')" />
<div v-if="news?.length" class="lg:w-4/5 sm:w-full grid sm:grid-cols-1 lg:grid-cols-3 gap-12">
<AppNews v-for="n in news" :key="n.id" :news="n" />
</div>
</div>
</template>
22 replies
Download and serve NuxtImg's from /public folder when generating with SSR true
@kapa.ai 1. is actually what i want - does this only work for images being embeded from the public folder? It doesnt seem to work from images being mebded from an external source (directus).
19 replies