Skip to content

Commit

Permalink
chore: Lighthouse improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
macx committed Apr 2, 2024
1 parent b49b044 commit 5ebd43c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/Figure.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ interface Props {
imageFormat?: string
alt?: string
caption?: string | boolean
lazy?: boolean
}
const { imagePath, imageFormat, caption, alt } = Astro.props
const { imagePath, imageFormat, caption, alt, lazy = true } = Astro.props
const images = import.meta.glob<{ default: ImageMetadata }>(
'/src/images/**/*.{jpeg,jpg,png}'
Expand All @@ -32,6 +33,7 @@ if (imagePath !== undefined && !images[imagePath]) {
sizes={`(max-width: 480px) 380px, (max-width: 800) 670px, 710px`}
format={imageFormat ? 'png' : undefined}
alt={alt}
loading={lazy ? 'lazy' : 'eager'}
/>
) : (
<slot />
Expand Down
8 changes: 6 additions & 2 deletions src/components/Navigation.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const filteredPages = pages
.sort((a, b) => (a.frontmatter.sort > b.frontmatter.sort ? 0 : -1))
---

<nav role='navigation' class='navigation' aria-role='navigation'>
<nav role='navigation' class='navigation'>
<div class='navigation-items'>
<ul>
<li class='home'>
Expand Down Expand Up @@ -86,7 +86,11 @@ const filteredPages = pages
<ThemeButton />
</li>
<li>
<a href='#top' class='header-button js-toggle-nav'>
<a
href='#top'
class='header-button js-toggle-nav'
title='Nach oben scrollen'
>
<Icon name='material-symbols:arrow-upward-rounded' />
</a>
</li>
Expand Down
1 change: 1 addition & 0 deletions src/components/ThemeButton.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
id='themeToggle'
aira-hidden='true'
arial-labeledby='theme-toggle-button'
title='Theme ändern'
>
<svg
width='30px'
Expand Down
1 change: 1 addition & 0 deletions src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const { title, description, pubDate, toc, cover, ogType } =
let button = document.createElement('button')
button.className = 'copy-code-btn'
button.innerHTML = copyIcon
button.title = 'Code in die Zwischenablage kopieren'
codeBlock.appendChild(button)

button.addEventListener('click', async () => {
Expand Down
1 change: 1 addition & 0 deletions src/layouts/BlogPostLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const toc = true
imagePath={cover.path}
caption={cover.caption}
alt={cover.alt}
lazy={false}
/>
)
}
Expand Down

0 comments on commit 5ebd43c

Please sign in to comment.