Skip to content

Commit

Permalink
feat: nuxt-themes#137 add nuxt img integration resulting in modern im…
Browse files Browse the repository at this point in the history
…age formats and responsive sizes by default, improves performance (mobile).
  • Loading branch information
BillyBouman-2B-IT committed May 22, 2023
1 parent 7ceddd9 commit 649f370
Show file tree
Hide file tree
Showing 7 changed files with 1,774 additions and 1,573 deletions.
4 changes: 2 additions & 2 deletions components/AppHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const show = ref(false)
<NuxtLink v-if="alpine.header.logo" to="/">
<!-- TODO: width/height doesn't make much sense here, but Lighthouse requires it.
Used current Alpine logo ratio, will break on enduser logo -->
<NuxtImg class="dark-img" :src="alpine.header.logo.pathDark" :alt="alpine.header.logo.alt" width="89" height="31" />
<NuxtImg class="light-img" :src="alpine.header.logo.path" :alt="alpine.header.logo.alt" width="89" height="31" />
<NuxtPicture class="dark-img" :src="alpine.header.logo.pathDark" :alt="alpine.header.logo.alt" width="89" height="31" fetchpriority="high" decoding="sync" loading="eager" />
<NuxtPicture class="light-img" :src="alpine.header.logo.path" :alt="alpine.header.logo.alt" width="89" height="31" fetchpriority="high" decoding="sync" loading="eager" />
</NuxtLink>
<NuxtLink v-else to="/" class="fallback">
{{ alpine.title }}
Expand Down
11 changes: 7 additions & 4 deletions components/content/ArticlesListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ const id = computed(() => {
</span>
</div>
<NuxtLink :to="article._path">
<NuxtImg
<NuxtPicture
v-if="article.cover"
:src="article.cover"
:alt="article.title"
width="16"
height="9"
width="432"
height="243"
:decoding="featured ? 'sync' : 'async'"
:fetchpriority="featured ? 'high' : 'low'"
:loading="featured ? 'eager' : 'lazy'"
/>
</NuxtLink>
</div>
Expand All @@ -80,7 +83,7 @@ const id = computed(() => {
</article>
</template>

<style scoped lang="ts">
<style lang="ts">
css({
article: {
display: 'flex',
Expand Down
9 changes: 5 additions & 4 deletions components/content/Gallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@ defineProps({
<div
class="layout"
>
<NuxtImg
<NuxtPicture
v-for="(image, index) in images"
:key="index"
:src="image"
:width="16"
:height="9"
:width="418"
:height="236"
loading="lazy"
/>
</div>
</section>
</template>

<style scoped lang="ts">
<style lang="ts">
css({
'.gallery': {
'.layout': {
Expand Down
15 changes: 9 additions & 6 deletions components/content/Hero.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,22 @@ defineProps({
</ContentSlot>
</div>
</div>
<NuxtImg
<NuxtPicture
v-if="image"
:class="imagePosition"
:img-attrs="{ class: [imagePosition, 'hero-image'] }"
:src="image"
:alt="imageAlt"
:width="16"
:height="9"
:width="432"
:height="288"
fetchpriority="high"
decoding="sync"
loading="eager"
/>
</div>
</section>
</template>

<style scoped lang="ts">
<style lang="ts">
css({
'.hero': {
'.layout': {
Expand Down Expand Up @@ -70,7 +73,7 @@ css({
'&.left': {
order: -1
}
},
}
}
}
})
Expand Down
1 change: 1 addition & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default defineNuxtConfig({
envModules.tokens,
envModules.studio,
'@nuxt/content',
'@nuxt/image-edge',
updateModule as any
],
components: [
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"devDependencies": {
"@nuxt/eslint-config": "^0.1.1",
"@nuxt/image-edge": "1.0.0-28059208.2abef1b",
"@nuxtjs/plausible": "^0.2.1",
"@types/node": "^20.1.5",
"eslint": "^8.40.0",
Expand Down
Loading

0 comments on commit 649f370

Please sign in to comment.