Bootstrap
Today I added some features into the site:
- Added tag pills at the bottom of blog post layout.
- Added Bootstrap CSS for styling.
Tag Pills
- First I update the blog schema in
src/content.config.ts
, adding thetags
field.
tags: z.array(z.string()).optional(),
- Then in
BlogPost.astro
, addtags
new props:
const { ..., heroImage, tags } = Astro.props;
- Finally adding the markup:
<div style="display: flex;">
{tags && tags.map((tag: string) =>
<div><span class="badge text-bg-secondary">#{tag}</span> </div>
)}
</div>
Adding Bootstrap CSS
- Install Bootstrap:
yarn add bootstrap
- Import the bootstrap CSS into
BaseHead.astro
:
import 'bootstrap/dist/css/bootstrap.min.css';
That’s it. I can use the color classes now! :rocket: