Skip to content

Commit

Permalink
Add some page caching to the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobefu committed Apr 21, 2024
1 parent 77ac319 commit a6d0c6e
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 51 deletions.
44 changes: 22 additions & 22 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions frontend/base/components/layout/LayoutHeaderMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import type { MenuAvailable } from '#build/graphql-operations'
const { locale } = useI18n()
const localePath = useLocalePath()
const user = await useAuth()
const route = useRoute()
const { data: menu, refresh } = await useAsyncData(
const { data: menu } = await useAsyncData(
'menu',
async () => await useGraphqlQuery(
'menu',
Expand All @@ -15,12 +16,8 @@ const { data: menu, refresh } = await useAsyncData(
langcode: locale.value,
},
),
)
watch(
() => locale.value,
async () => {
await refresh()
{
watch: [locale, () => user],
},
)
Expand Down
6 changes: 6 additions & 0 deletions frontend/base/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ export default defineNuxtConfig({
},

routeRules: {
'/**': {
cache: {
maxAge: process.env.NODE_ENV === 'development' ? 0 : 60,
},
},
'/api/**': {
robots: false,
sitemap: false,
cache: false,
cors: true,
},
'/preview/**': {
Expand Down
35 changes: 22 additions & 13 deletions frontend/themes/default/components/base/BaseSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,28 @@ const model = defineModel()
</script>

<template>
<select
:id="id"
v-model="model"
:aria-label="label"
class="bg-white dark:bg-stone-950"
<div
class="relative flex items-center"
>
<option
v-for="option in options"
:key="option.value"
:value="option.value"
:selected="model === option.value"
<select
:id="id"
v-model="model"
:aria-label="label"
class="px-2 py-1 pr-6 bg-white rounded-lg appearance-none dark:bg-stone-950"
>
{{ option.label }}
</option>
</select>
<option
v-for="option in options"
:key="option.value"
:value="option.value"
:selected="model === option.value"
>
{{ option.label }}
</option>
</select>

<Icon
name="mdi:chevron-up-down"
class="absolute w-4 h-4 right-1"
/>
</div>
</template>
2 changes: 1 addition & 1 deletion frontend/themes/default/components/layout/LayoutFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config = useRuntimeConfig()

<template>
<footer class="bg-white dark:bg-stone-950">
<div class="flex justify-between max-w-6xl px-4 py-8 m-auto text-gray-600 dark:text-gray-400 md:px-8">
<div class="flex items-center justify-between max-w-6xl px-4 py-8 m-auto text-gray-600 dark:text-gray-400 md:px-8">
<span class="text-sm">
{{ config.public.siteName }} &copy; {{ new Date().getFullYear() }}
</span>
Expand Down
2 changes: 1 addition & 1 deletion frontend/themes/default/components/layout/LayoutHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const localePath = useLocalePath()
>
<div class="flex items-center gap-6">
<NuxtLink
class="flex items-center gap-2 text-xl md:text-2xl"
class="flex items-center gap-4 text-xl md:gap-6 md:text-2xl"
:to="localePath('/')"
>
<NuxtImg
Expand Down
11 changes: 4 additions & 7 deletions frontend/themes/default/components/layout/LayoutHeaderMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import type { MenuAvailable } from '#build/graphql-operations'
const { locale } = useI18n()
const localePath = useLocalePath()
const user = await useAuth()
const route = useRoute()
const { data: menu, refresh } = await useAsyncData(
const { data: menu } = await useAsyncData(
'menu',
async () => await useGraphqlQuery(
'menu',
Expand All @@ -15,12 +16,8 @@ const { data: menu, refresh } = await useAsyncData(
langcode: locale.value,
},
),
)
watch(
() => locale.value,
async () => {
await refresh()
{
watch: [locale, () => user],
},
)
Expand Down

0 comments on commit a6d0c6e

Please sign in to comment.