Skip to content

Commit

Permalink
Merge branch 'optimizations'
Browse files Browse the repository at this point in the history
  • Loading branch information
louderthan10 committed Nov 28, 2024
2 parents 913f092 + 3fd0072 commit c79b9f4
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 29 deletions.
6 changes: 2 additions & 4 deletions frontend/components/header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ const props = defineProps({
}
})
// Get the site name from the global entry
const siteName = computed(() => {
return useRuntimeConfig().public.SITE_NAME || 'Site Name'
})
const { public: { SITE_NAME } } = useRuntimeConfig()
const siteName = computed(() => SITE_NAME || 'Site Name')
</script>

<template>
Expand Down
22 changes: 7 additions & 15 deletions frontend/components/image.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
<script setup>
const props = defineProps({
image: {
type: String,
type: Object,
required: true
}
})
}
const getPhotoUrl = (photo, width) => {
return `${photo.url}?width=${width}`
}
</script>

<template>
<picture>
<source data-sizes="100vw" />
<img
:src="image.url"
:srcset="image.srcset"
:alt="image.alt"
sizes="100vw"
/>
</picture>
<nuxt-img
:src="image.url"
:alt="image.alt"
sizes="sm:100vw md:50vw lg:400px"
loading="lazy"
/>
</template>
10 changes: 7 additions & 3 deletions frontend/components/navigation.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<script setup>
const route = useRoute()
defineProps({
pages: {
type: Array,
default: () => []
}
})
const isCurrentPage = (path) => route.path === path
</script>

<template>
Expand All @@ -15,7 +19,7 @@ defineProps({
to="/blog"
class="block p-2 hover:underline text-red-600 hover:text-red-600"
active-class="text-red-600"
:aria-current="$route.path === '/blog' ? 'page' : null"
:aria-current="isCurrentPage('/blog') ? 'page' : null"
>
Blog
</NuxtLink>
Expand All @@ -25,7 +29,7 @@ defineProps({
to="/guestbook"
class="block p-2 hover:underline text-red-600 hover:text-red-600"
active-class="text-red-600"
:aria-current="$route.path === '/guestbook' ? 'page' : null"
:aria-current="isCurrentPage('/guestbook') ? 'page' : null"
>
Guestbook
</NuxtLink>
Expand All @@ -35,7 +39,7 @@ defineProps({
:to="`/${page.uri}`"
class="block p-2 hover:underline text-red-600 hover:text-red-600"
active-class="text-red-600"
:aria-current="$route.path === `/${page.uri}` ? 'page' : null"
:aria-current="isCurrentPage(`/${page.uri}`) ? 'page' : null"
>
{{ page.title }}
</NuxtLink>
Expand Down
1 change: 0 additions & 1 deletion frontend/composables/useFlashes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export function useFlashes() {
const id = Date.now()
flashes.value.push({ id, message, level })

// Auto-remove after 5 seconds
setTimeout(() => {
removeFlash(id)
}, 5000)
Expand Down
1 change: 0 additions & 1 deletion frontend/pages/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const { data: pageData, refresh } = await useAsyncData(
}
)
// Watch for preview changes and refresh data
watch([isPreview, previewToken], () => {
if (isPreview.value && previewToken.value) {
refresh()
Expand Down
3 changes: 1 addition & 2 deletions frontend/pages/blog/[slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const { data, error, refresh } = await useAsyncData(
}
},
{
watch: [previewToken] // Watch preview token for changes
watch: [previewToken]
}
)
Expand All @@ -54,7 +54,6 @@ watch([isPreview, previewToken], () => {
}
})
// Computed property for cleaner template
const currentPost = computed(() => data.value?.blogPostsEntries?.[0] || null)
const hasPost = computed(() => !!currentPost.value)
const hasNextPrev = computed(() => hasPost.value && (currentPost.value?.prev || currentPost.value?.next))
Expand Down
3 changes: 1 addition & 2 deletions frontend/pages/guestbook.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (isPreview.value) {
definePageMeta({ ssr: false })
}
// Data fetching using useAsyncData
// Data fetching
const {
data: content,
error,
Expand Down Expand Up @@ -51,7 +51,6 @@ const handleNewPost = async () => {
}
}
// Watch for preview changes
watch([isPreview, previewToken], () => {
if (isPreview.value && previewToken.value) {
refreshContent()
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const { data, refresh } = await useAsyncData(
}
},
{
watch: [previewToken] // Automatically watch preview token
watch: [previewToken]
}
)
Expand Down

0 comments on commit c79b9f4

Please sign in to comment.