diff --git a/src/components/Breadcrumbs.astro b/src/components/Breadcrumbs.astro index b1a54ad..1ad36a8 100644 --- a/src/components/Breadcrumbs.astro +++ b/src/components/Breadcrumbs.astro @@ -1,78 +1,36 @@ --- -export async function getStaticPaths() { - // Define all pages with their titles - const pages = [ - { href: '/', title: 'หน้าแรก' }, - { href: '/about-us', title: 'เกี่ยวกับเรา' }, - { href: '/contact-us', title: 'ติดต่อเรา' }, - { href: '/web-development', title: 'AI-Enhanced Website' }, - { href: '/marketing-automation', title: 'Marketing Automation' }, - { href: '/seo-content-system', title: 'SEO + AI Content' }, - { href: '/tech-consult', title: 'Tech Consult' }, - { href: '/ai-automation', title: 'AI Automation' }, - { href: '/faq', title: 'FAQ' }, - { href: '/blog', title: 'บทความ' }, - ]; - - return pages.map((page) => ({ - params: { currentPage: page.href }, - props: { currentPage: page }, - })); -} - -interface Props { +export interface Props { currentPage: { href: string; title: string }; } const { currentPage } = Astro.props; -// Helper function to determine breadcrumb path -function getBreadcrumbPath(href: string) { - if (href === '/') return [{ href: '/', title: 'หน้าแรก' }]; - - const paths = href.split('/').filter(Boolean); - const breadcrumb = [{ href: '/', title: 'หน้าแรก' }]; - - let accumulatedPath = ''; - for (const path of paths) { - accumulatedPath += '/' + path; - breadcrumb.push({ - href: accumulatedPath, - title: pages.find(p => p.href === accumulatedPath)?.title || path, - }); - } - - return breadcrumb; +// Simple breadcrumb path generator +const paths = currentPage.href.split('/').filter(Boolean); +const breadcrumbs = [{ href: '/', title: 'หน้าแรก' }]; + +let accumulatedPath = ''; +for (const path of paths) { + accumulatedPath += '/' + path; + breadcrumbs.push({ + href: accumulatedPath, + title: path.charAt(0).toUpperCase() + path.slice(1).replace(/-/g, ' '), + }); } - -const pages = [ - { href: '/', title: 'หน้าแรก' }, - { href: '/about-us', title: 'เกี่ยวกับเรา' }, - { href: '/contact-us', title: 'ติดต่อเรา' }, - { href: '/web-development', title: 'AI-Enhanced Website' }, - { href: '/marketing-automation', title: 'Marketing Automation' }, - { href: '/seo-content-system', title: 'SEO + AI Content' }, - { href: '/tech-consult', title: 'Tech Consult' }, - { href: '/ai-automation', title: 'AI Automation' }, - { href: '/faq', title: 'FAQ' }, - { href: '/blog', title: 'บทความ' }, -]; - -const breadcrumbPath = getBreadcrumbPath(currentPage.href); ---