Skip to content
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

feat: #137 add nuxt img integration resulting in modern image and responsive sizes by default, improves performance (mobile). #146

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 }"
: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
5 changes: 3 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ const updateModule = defineNuxtModule({
meta: {
name: '@nuxt-themes/alpine'
},
setup (_, nuxt) {
setup(_, nuxt) {
if (nuxt.options.dev) {
$fetch('https://registry.npmjs.org/@nuxt-themes/alpine/latest').then((release) => {
if (release.version > version) {
logger.info(`A new version of Alpine (v${release.version}) is available: https://github.com/nuxt-themes/alpine/releases/latest`)
}
}).catch(() => {})
}).catch(() => { })
}
}
})
Expand All @@ -47,6 +47,7 @@ export default defineNuxtConfig({
envModules.tokens,
envModules.studio,
'@nuxt/content',
'@nuxt/image',
updateModule as any
],
components: [
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
},
"devDependencies": {
"@nuxt/eslint-config": "^0.1.1",
"@nuxt/image": "1.0.0-rc.1",
"@nuxtjs/plausible": "^0.2.1",
"@types/node": "^20.2.5",
"eslint": "^8.42.0",
"nuxt": "^3.5.3",
"nuxt": "^3.6.0",
"release-it": "^15.11.0",
"typescript": "^5.1.3",
"vite-plugin-inspect": "^0.7.28",
Expand Down