-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breadcrumbs: Page title #11
Comments
Hello 👋 Where is your You can use slots to override the default HTML for the Breadcrumbs. I haven't tested this, but it should look something like this: ---
import { getEntry } from 'astro:content';
function getCollectionIdFromURL(href: string) {
// ...
}
---
<Breadcrumb>
{async ({ href, text }) => {
const id = getCollectionIdFromURL(href)
// If URL is a content collection entry
if (id) {
const entry = getEntry('blog', id)
return <a {href}>{entry.data.title}</a>
}
return <a {href}>{text }</a>
}}
</Breadcrumb> The |
Yes,
Thank you for the feedback! |
I think I have a different solution that works for my current needs. ---
const { title } = Astro.props;
function camelCaseString(str) {
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase().trim();
}
---
<Breadcrumbs>
{url => (<a href={url.href}>{camelCaseString(url.text)}</a><span>></span>)}
<active slot="active">{url => <span>{title}</span>}</active>
</Breadcrumbs>
|
For Breadcrumbs, how can I have the output text be the page
title
, rather than theslug
?I still want a link, but the links should be page titles.
The text was updated successfully, but these errors were encountered: