Adding the Author Component
Learn how we can build an Author component in Astro for establishing authority.
Adding an Author
component can help us reference the author on several pages across a site, establishing credibility and showcasing that information has been created by an experienced person and not autogenerated by AI. In this lesson, we’ll take a look at how we can create a reusable, responsive Author
component and what necessary information to include.
Creating the Author
component
In the following code widget, we already have an empty Author
component. To create the base for the component, open the file and create a new section
element under h2
and add the following two elements inside it:
div
: Create adiv
element with a class of.author-info
and leave it empty for now. This is where we’re going to add a profile picture as well as the name and the role of our author.p
: Inside the paragraph, referenceauthor.about
. Make sure to import theauthor
object from the configuration file at the top of the component.
--- title: "Latest Astro Post Title" description: "Description for the post" publishDate: "2023.06.19" heroImage: "https://images.unsplash.com/photo-1581500274180-6331eea8b184?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8OHx8YXN0cm98ZW58MHx8MHx8fDA%3D&auto=format&fit=crop&w=1200&q=60" excerpt: "Excerpt from a recommended article. Content is trimmed to a maximum of 150 characters for brevity. If the content exceeds the character limit, three dots will be displayed using JavaScript's `substring` method." faq: - id: 1 question: "Post with FAQ" answer: "FAQ answer" open: true - id: 2 question: "FAQ 2nd Question" answer: "Answer to 2nd FAQ" --- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae ultricies leo integer malesuada nunc vel risus commodo viverra. Adipiscing enim eu turpis egestas pretium. Euismod elementum nisi quis eleifend quam adipiscing. In hac habitasse platea dictumst vestibulum. Sagittis purus sit amet volutpat. Netus et malesuada fames ac turpis egestas. Eget magna fermentum iaculis eu non diam phasellus vestibulum lorem. Varius sit amet mattis vulputate enim. Habitasse platea dictumst quisque sagittis. Integer quis auctor elit sed vulputate mi. Dictumst quisque sagittis purus sit amet. Morbi tristique senectus et netus. Id semper risus in hendrerit gravida rutrum quisque non tellus. Habitasse platea dictumst quisque sagittis purus sit amet. Tellus molestie nunc non blandit massa. Cursus vitae congue mauris rhoncus. Accumsan tortor posuere ac ut. Fringilla urna porttitor rhoncus dolor. Elit ullamcorper dignissim cras tincidunt lobortis. In cursus turpis massa tincidunt dui ut ornare lectus. Integer feugiat scelerisque varius morbi enim nunc. Bibendum neque egestas congue quisque egestas diam. Cras ornare arcu dui vivamus arcu felis bibendum. Dignissim suspendi --- ## Title Morbi tristique senectus et netus. Id semper risus in hendrerit gravida rutrum quisque non tellus. Habitasse platea dictumst quisque sagittis purus sit amet. Tellus molestie nunc non blandit massa. Cursus vitae congue mauris rhoncus. Accumsan tortor posuere ac ut. Fringilla urna porttitor rhoncus dolor. Elit ullamcorper dignissim cras tincidunt lobortis. In cursus turpis massa tincidunt dui ut ornare lectus. Integer feugiat scelerisque varius morbi enim nunc. Bibendum neque egestas congue quisque egestas diam. Cras ornare arcu dui vivamus arcu felis bibendum. Dignissim suspendi - List - With - Items - With Adjusted Styles
Inside the .author-info
block, add the following lines of code to display the profile ...