mirror of
https://github.com/mmahdium/portfolio.git
synced 2026-09-28 02:21:41 +03:30
feat: enhance blog components, improve routing, and add clean script for build process
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<UInput :model-value="modelValue" :placeholder="t('blog.searchPlaceholder')" icon="i-heroicons-magnifying-glass"
|
||||
size="lg" :ui="{ icon: { trailing: { pointer: '' } } }" @update:model-value="handleInput">
|
||||
size="lg" @update:model-value="handleInput">
|
||||
<template v-if="modelValue" #trailing>
|
||||
<UButton color="gray" variant="link" icon="i-heroicons-x-mark-20-solid" :padded="false" @click="clearSearch" />
|
||||
</template>
|
||||
|
||||
@@ -26,6 +26,12 @@ const shouldShowToc = computed(() => {
|
||||
return countLinks(props.toc.links) >= 3
|
||||
})
|
||||
|
||||
const setHashWithoutNavigation = (id: string) => {
|
||||
const url = new URL(window.location.href)
|
||||
url.hash = id
|
||||
window.history.replaceState(window.history.state, '', url.toString())
|
||||
}
|
||||
|
||||
// Smooth scroll to heading with offset for sticky header
|
||||
const scrollToHeading = (id: string) => {
|
||||
const element = document.getElementById(id)
|
||||
@@ -40,11 +46,28 @@ const scrollToHeading = (id: string) => {
|
||||
})
|
||||
|
||||
activeId.value = id
|
||||
setHashWithoutNavigation(id)
|
||||
}
|
||||
}
|
||||
|
||||
// Track active section with IntersectionObserver
|
||||
onMounted(() => {
|
||||
// Handle initial hash (avoid full page navigation / transition)
|
||||
const initialId = window.location.hash.replace(/^#/, '')
|
||||
if (initialId) {
|
||||
setTimeout(() => {
|
||||
const el = document.getElementById(initialId)
|
||||
if (!el) return
|
||||
|
||||
const offset = 100
|
||||
const elementPosition = el.getBoundingClientRect().top + window.pageYOffset
|
||||
const offsetPosition = elementPosition - offset
|
||||
|
||||
window.scrollTo({ top: offsetPosition, behavior: 'auto' })
|
||||
activeId.value = initialId
|
||||
}, 0)
|
||||
}
|
||||
|
||||
const headings = document.querySelectorAll('article h2, article h3, article h4')
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
<UContainer>
|
||||
<div class="flex flex-col items-center gap-4 text-center text-sm text-gray-600 dark:text-gray-400">
|
||||
<ClientOnly>
|
||||
<NuxtImg :src="logoSrc" alt="Ali Arghyani logo" width="64" height="64" class="h-12 w-12" format="png"
|
||||
loading="lazy" />
|
||||
<img :src="logoSrc" alt="Ali Arghyani logo" width="64" height="64" class="h-12 w-12" loading="lazy" />
|
||||
<template #fallback>
|
||||
<NuxtImg src="/favicon/android-chrome-192x192.png" alt="Ali Arghyani logo" width="64" height="64"
|
||||
class="h-12 w-12" format="png" loading="lazy" />
|
||||
<img src="/favicon/android-chrome-192x192.png" alt="Ali Arghyani logo" width="64" height="64"
|
||||
class="h-12 w-12" loading="lazy" />
|
||||
</template>
|
||||
</ClientOnly>
|
||||
<p>© {{ currentYear }}, <span class="font-semibold text-gray-900 dark:text-gray-100">AliArghyani</span> -
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<template>
|
||||
<UCard :ui="{
|
||||
base: 'my-6',
|
||||
body: { padding: 'p-4 sm:p-5' },
|
||||
ring: 'ring-2',
|
||||
divide: ''
|
||||
root: 'my-6 ring-2',
|
||||
body: 'p-4 sm:p-5'
|
||||
}" :class="cardClass">
|
||||
<div class="flex items-start gap-3">
|
||||
<UIcon :name="icon" :class="iconClass" class="mt-0.5 h-5 w-5 flex-shrink-0" />
|
||||
|
||||
Reference in New Issue
Block a user