這個Astro佈局教程摘錄,摘自釋放Astro的功能(在SitePoint Premium上可用),展示了有效的網站結構。 雖然每個Astro頁面都可以包含一個完整的HTML文檔,但使用佈局可以避免冗餘。這對於<meta>
和<title></title>
標籤等元素特別有益,該元素通常每頁不同。
>建議在src/layouts
layouts/Layout.astro
layouts/Head.astro
content。
>
layouts/Nav.astro
layouts/Footer.astro
>文件可能看起來像這樣:layouts/Layout.astro
--- import Head from './Head.astro'; import Nav from './Nav.astro'; const { title = 'Footie is the best', description = 'An online football magazine' } = Astro.props; import Footer from './Footer.astro'; --- <html lang="en"> <head> <Head /> <title>{title}</title> <meta content="{description}" name="description"> </head> <body> <Nav /> <main> <slot /> </main> <Footer /> </body> </html>
以上是Astro的佈局的詳細內容。更多資訊請關注PHP中文網其他相關文章!