Skip to content

Commit e6fd339

Browse files
committed
🎉 feat: lazy load image
1 parent 17aa6d2 commit e6fd339

File tree

4 files changed

+63
-24
lines changed

4 files changed

+63
-24
lines changed

components/midori/community.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
allowtransparency="true"
3030
frameborder="0"
3131
sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"
32+
loading="lazy"
3233
/>
3334
</section>
3435
</article>

components/midori/index.vue

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,20 @@ const isDark = useDark()
2525

2626
<template>
2727
<link rel="preconnect" href="https://fonts.googleapis.com" />
28-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="true" />
28+
<link
29+
rel="preconnect"
30+
href="https://fonts.gstatic.com"
31+
crossorigin="true"
32+
/>
2933

3034
<div id="landing" class="dark:bg-gray-900/60">
3135
<Hero />
3236
<article class="flex flex-col gap-4 px-6">
3337
<Fast />
3438
<Simple />
35-
<section class="flex flex-col justify-center items-center gap-8 w-full mt-4 mb-16">
39+
<section
40+
class="flex flex-col justify-center items-center gap-8 w-full mt-4 mb-16"
41+
>
3642
<JustReturn>
3743
<slot name="justreturn"></slot>
3844
</JustReturn>
@@ -64,9 +70,14 @@ const isDark = useDark()
6470
<Sponsor />
6571
<hr class="border-gray-200 dark:border-gray-600" />
6672
<figure
67-
class="max-w-6xl w-full mx-auto rounded-2xl overflow-hidden my-12 shadow-xl bg-gray-50 dark:bg-gray-800">
68-
<img class="w-full object-cover object-center" src="/assets/feature-sheet.webp"
69-
alt="Elysia Feature Sheet" />
73+
class="max-w-6xl w-full mx-auto rounded-2xl overflow-hidden my-12 shadow-xl bg-gray-50 dark:bg-gray-800"
74+
>
75+
<img
76+
class="w-full object-cover object-center"
77+
src="/assets/feature-sheet.webp"
78+
alt="Elysia Feature Sheet"
79+
loading="lazy"
80+
/>
7081
</figure>
7182
<QuickStart />
7283
<BuiltWithLove />
@@ -75,7 +86,7 @@ const isDark = useDark()
7586
</template>
7687

7788
<style>
78-
#landing div[class*='language-']>pre>code {
89+
#landing div[class*='language-'] > pre > code {
7990
display: block;
8091
width: -moz-fit-content;
8192
width: fit-content;
@@ -87,16 +98,16 @@ const isDark = useDark()
8798
font-size: 16px;
8899
}
89100
90-
#landing div[class*='language-']>pre {
101+
#landing div[class*='language-'] > pre {
91102
position: relative;
92103
z-index: 1;
93104
padding: 1em;
94105
background: transparent;
95106
overflow-x: auto;
96107
}
97108
98-
#landing div[class*='language-']>span.lang,
99-
#landing div[class*='language-']>button {
109+
#landing div[class*='language-'] > span.lang,
110+
#landing div[class*='language-'] > button {
100111
display: none;
101112
}
102113

components/midori/plugins.vue

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ const plugins = [
55
['tRPC', '/assets/trpc.webp', '/plugins/trpc'],
66
['Vite', '/assets/vite.svg', 'https://github.com/timnghg/elysia-vite'],
77
['JWT', '/assets/jwt.webp', '/plugins/jwt'],
8-
['Web Socket', '/assets/websocket.webp', '/patterns/websocket', '/assets/websocket-dark.webp'],
8+
[
9+
'Web Socket',
10+
'/assets/websocket.webp',
11+
'/patterns/websocket',
12+
'/assets/websocket-dark.webp'
13+
],
914
[
1015
'Clerk',
1116
'/assets/clerk.webp',
@@ -30,11 +35,14 @@ const isDark = useDark()
3035
</script>
3136

3237
<template>
33-
<article class="flex justify-between flex-col lg:flex-row items-center w-full max-w-6xl mx-auto my-8 gap-12">
38+
<article
39+
class="flex justify-between flex-col lg:flex-row items-center w-full max-w-6xl mx-auto my-8 gap-12"
40+
>
3441
<section class="flex flex-col w-full max-w-lg">
3542
<header class="flex flex-col justify-center items-start">
3643
<h2
37-
class="text-5xl md:text-6xl leading-tight font-bold bg-clip-text text-transparent bg-gradient-to-tr from-sky-400 to-fuchsia-400 mb-4">
44+
class="text-5xl md:text-6xl leading-tight font-bold bg-clip-text text-transparent bg-gradient-to-tr from-sky-400 to-fuchsia-400 mb-4"
45+
>
3846
It works with that
3947
</h2>
4048
</header>
@@ -43,25 +51,43 @@ const isDark = useDark()
4351
likely there is a plugin for what you want.
4452
</p>
4553
<p class="text-xl text-gray-400 w-full max-w-lg">
46-
If the plugin you need is not there, it's easy to create one and share
47-
it with the community.
54+
If the plugin you need is not there, it's easy to create one and
55+
share it with the community.
4856
</p>
4957
<div class="mt-8">
50-
<a href="/plugins/overview"
51-
class="text-xl font-medium bg-blue-200/25 dark:bg-blue-500/25 text-blue-500 px-6 py-3 rounded-xl">
58+
<a
59+
href="/plugins/overview"
60+
class="text-xl font-medium bg-blue-200/25 dark:bg-blue-500/25 text-blue-500 px-6 py-3 rounded-xl"
61+
>
5262
Explore plugins
5363
</a>
5464
</div>
5565
</section>
5666
<section class="flex flex-col w-full max-w-xl">
57-
<ol class="grid grid-cols-2 sm:grid-cols-3 gap-4 list-none w-full text-gray-500 dark:text-gray-400 text-lg">
58-
<li v-for="[name, icon, href, darkIcon = ''] in plugins"
59-
class="aspect-square rounded-xl border dark:border-gray-700 bg-gradient-to-br from-white to-gray-50 dark:from-gray-700/75 dark:to-gray-800/75 text-xl transform transition-all ease-out duration-200 hover:shadow-lg focus:shadow-lg hover:-translate-y-1.5 focus:-translate-y-1.5">
60-
<a :href="href" :target="href.startsWith('http') ? '_blank' : ''"
61-
class="flex flex-col justify-center items-center gap-3 w-full h-full text-lg font-medium text-gray-600 dark:text-gray-400 overflow-hidden">
62-
<img :src="isDark && darkIcon ? darkIcon ?? icon : icon" :alt="name"
63-
class="absolute w-36 h-36 opacity-10 filter blur-lg" />
64-
<img :src="isDark && darkIcon ? darkIcon ?? icon : icon" :alt="name" class="h-14" />
67+
<ol
68+
class="grid grid-cols-2 sm:grid-cols-3 gap-4 list-none w-full text-gray-500 dark:text-gray-400 text-lg"
69+
>
70+
<li
71+
v-for="[name, icon, href, darkIcon = ''] in plugins"
72+
class="aspect-square rounded-xl border dark:border-gray-700 bg-gradient-to-br from-white to-gray-50 dark:from-gray-700/75 dark:to-gray-800/75 text-xl transform transition-all ease-out duration-200 hover:shadow-lg focus:shadow-lg hover:-translate-y-1.5 focus:-translate-y-1.5"
73+
>
74+
<a
75+
:href="href"
76+
:target="href.startsWith('http') ? '_blank' : ''"
77+
class="flex flex-col justify-center items-center gap-3 w-full h-full text-lg font-medium text-gray-600 dark:text-gray-400 overflow-hidden"
78+
>
79+
<img
80+
:src="isDark && darkIcon ? darkIcon ?? icon : icon"
81+
:alt="name"
82+
loading="lazy"
83+
class="absolute w-36 h-36 opacity-10 filter blur-lg"
84+
/>
85+
<img
86+
:src="isDark && darkIcon ? darkIcon ?? icon : icon"
87+
:alt="name"
88+
class="h-14"
89+
loading="lazy"
90+
/>
6591
{{ name }}
6692
</a>
6793
</li>

docs/blog/elysia-10.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ And finally, if you have problems with migration and additional questions relate
435435
allowtransparency="true"
436436
frameborder="0"
437437
sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"
438+
loadin="lazy"
438439
/>
439440
440441
## Notable Improvement

0 commit comments

Comments
 (0)