Create a social media footer
本頁內容尚未翻譯。
準備好……
- Create a Footer component
- Create and pass props to a Social Media component
Now that you have used Astro components on a page, it’s time to use a component within another component!
Create a Footer Component
Section titled Create a Footer Component-
Create a new file at the location
src/components/Footer.astro
. -
Copy the following code into your new file,
Footer.astro
.src/components/Footer.astro ---const platform = "github";const username = "withastro";---<footer><p>Learn more about my projects on <a href={`https://www.${platform}.com/${username}`}>{platform}</a>!</p></footer>
Import and use Footer.astro
Section titled Import and use Footer.astro-
Add the following import statement to the frontmatter in each of your three Astro pages (
index.astro
,about.astro
, andblog.astro
):import Footer from '../components/Footer.astro'; -
Add a new
<Footer />
component in your Astro template on each page, just before the closing</body>
tag to display your footer at the bottom of the page.<Footer /></body></html>