ម៉ឺនុយ​ក៏​ដូច​ក្បាល​ទំព័រ​ដែរ ត្រូវ​គេ​យក​ទៅ​ប្រើប្រាស់​ជាមួយ​គ្រប់​ទំព័រ​ទាំងអស់ ដូចនេះ​យើង​ចាំបាច់​ត្រូវ​បង្កើត​គំរូ​ម៉ឺនុយ​មួយ​ទុក​យក​ទៅ​ប្រើការ​ជាមួយ​នឹងគ្រប់​​ទំព័រ​ទាំងឡាយ​។

 

<!--src/layouts/Menu.astro-->
---
const { pageURL="/" } = Astro.props
---
<div class="bg-teal-500">
    <nav class="font-display max-w-5xl mx-auto flex items-center justify-between flex-wrap bg-teal-500 md:p-0 p-6">
        <div class="text-white mr-6">
          <a href="/"><img class="w-7 hover:opacity-75" src="/images/home.png" /></a>
        </div>
        <div id="menu-button" class="block md:hidden">
          <button class="flex items-center px-3 py-2 border rounded text-teal-200 border-teal-400 hover:text-white hover:border-white">
            <svg class="fill-current h-3 w-3" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><title>Menu</title><path d="M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z"/></svg>
          </button>
        </div>
        <div id="menu" class="hidden w-full flex-grow md:flex md:items-center md:w-auto">
          <div class="text-base md:flex-grow">
            <a href="#responsive-header" class="block md:inline-block text-white hover:opacity-75 p-2">
              ព័ត៌មាន
            </a>
            <a href="#responsive-header" class="block md:inline-block text-white hover:opacity-75 p-2">
              សិល្បៈ
            </a>
            <a href="#responsive-header" class="block md:inline-block text-white hover:opacity-75 p-2">
              វប្បធម៌
            </a>
            <a href="#responsive-header" class="block md:inline-block text-white hover:opacity-75 p-2">
              ភាពយន្ត
            </a>
            <a href="#responsive-header" class="block md:inline-block text-white hover:opacity-75 p-2">
              ទំនាក់ទំនង
            </a>
            <a href="#responsive-header" class="block md:inline-block text-white hover:opacity-75 p-2">
              អំពី​យើង​ខ្ញុំ
            </a>
          </div>
        </div>
    </nav>
</div>

<script>
    const button = document.querySelector('#menu-button')
    const menu = document.querySelector('#menu')
    
    button.addEventListener('click', () => {
    menu.classList.toggle('hidden')
})
</script>

 

<!--src/layouts/Base.astro-->
---
const { pageTitle="ទំព័រ​គ្រឹះ" } = Astro.props
import Header from "./Header.astro"
import Menu from "./Menu.astro"
---

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
        <meta name="generator" content={Astro.generator} />
        <title>{pageTitle}</title>
        <link rel="icon" href="/images/siteLogo.png" />
        <link href="/fonts/setup.css" rel="stylesheet" />
        <script is:inline src="/scripts/jquery.js"></script>
    </head>
    <body class="text-sm leading-normal">
        <Header siteTitle="ទស្សនាវដ្តី​យើង"/>
        <Menu pageURL="/"/>
        <slot/>
        <p>ជើង​ទំព័រ</p>
    </body>
</html>

 

Netlify: https://khmerweb-dynamic-blog.netlify.app

GitHub: https://github.com/Sokhavuth/dynamic-blog