Skip to content

Commit 9b7c049

Browse files
authored
fix: failed to execute 'observe' on 'ResizeObserver' on /modules (#2222)
1 parent 840270a commit 9b7c049

File tree

4 files changed

+2285
-2257
lines changed

4 files changed

+2285
-2257
lines changed

app/components/module/ModuleItem.vue

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,77 +6,89 @@ const emit = defineEmits<{
66
remove: [module: Module]
77
}>()
88
9-
const { module, showBadge = true, isAdded, showAddButton = true } = defineProps<{
10-
module: Module
11-
showBadge?: boolean
12-
isAdded: boolean
13-
showAddButton?: boolean
14-
}>()
9+
const props = withDefaults(
10+
defineProps<{
11+
module: Module
12+
showBadge?: boolean
13+
isAdded: boolean
14+
showAddButton?: boolean
15+
}>(),
16+
{
17+
showBadge: true,
18+
showAddButton: true
19+
}
20+
)
1521
1622
const { copy } = useClipboard()
1723
const { selectedSort } = useModules()
1824
const { track } = useAnalytics()
19-
const date = computed(() => {
20-
if (selectedSort.value.key === 'publishedAt') {
21-
return useTimeAgo(module.stats.publishedAt)
22-
}
2325
24-
return useTimeAgo(module.stats.createdAt)
25-
})
26+
const publishedAgo = useTimeAgo(() => props.module.stats.publishedAt)
27+
const createdAgo = useTimeAgo(() => props.module.stats.createdAt)
28+
29+
const relativeDate = computed(() =>
30+
selectedSort.value.key === 'publishedAt' ? publishedAgo.value : createdAgo.value
31+
)
32+
33+
const staticModuleDate = computed(() =>
34+
selectedSort.value.key === 'publishedAt'
35+
? formatDateByLocale('en', props.module.stats.publishedAt)
36+
: formatDateByLocale('en', props.module.stats.createdAt)
37+
)
2638
2739
function copyInstallCommand(moduleName: string) {
2840
track('Module Install Command Copied', { module: moduleName })
2941
const command = `npx nuxt@latest module add ${moduleName}`
3042
copy(command, { title: 'Command copied to clipboard:', description: command })
3143
}
3244
33-
function toggleModule(module: Module) {
34-
const action = isAdded ? 'remove' : 'add'
35-
track('Module Toggled', { module: module.name, action })
36-
if (isAdded) {
37-
emit('remove', module)
45+
function toggleModule(m: Module) {
46+
const action = props.isAdded ? 'remove' : 'add'
47+
track('Module Toggled', { module: m.name, action })
48+
if (props.isAdded) {
49+
emit('remove', m)
3850
} else {
39-
emit('add', module)
51+
emit('add', m)
4052
}
4153
}
4254
4355
function handleCardClick(event: MouseEvent) {
4456
if (event.shiftKey) {
4557
event.preventDefault()
46-
toggleModule(module)
58+
toggleModule(props.module)
4759
}
4860
}
4961
5062
const items = computed(() => [
5163
[
5264
{
53-
label: isAdded ? 'Remove module' : 'Add module',
54-
icon: isAdded ? 'i-lucide-minus' : 'i-lucide-plus',
55-
onSelect: () => toggleModule(module)
65+
label: props.isAdded ? 'Remove module' : 'Add module',
66+
icon: props.isAdded ? 'i-lucide-minus' : 'i-lucide-plus',
67+
onSelect: () => toggleModule(props.module)
5668
},
5769
{
5870
label: 'Copy install command',
5971
icon: 'i-lucide-terminal',
60-
onSelect: () => copyInstallCommand(module.name)
72+
onSelect: () => copyInstallCommand(props.module.name)
6173
}
6274
],
6375
[
6476
{
6577
icon: 'i-lucide-book',
6678
label: 'Documentation',
67-
to: `${module.website}?utm_source=nuxt.com&utm_medium=aside-module&utm_campaign=nuxt.com`,
79+
to: `${props.module.website}?utm_source=nuxt.com&utm_medium=aside-module&utm_campaign=nuxt.com`,
6880
target: '_blank'
6981
},
7082
{
7183
label: 'View on GitHub',
7284
icon: 'i-lucide-github',
73-
to: `https://github.com/${module.repo}`,
85+
to: `https://github.com/${props.module.repo}`,
7486
target: '_blank'
7587
},
7688
{
7789
label: 'View on npm',
7890
icon: 'i-lucide-package',
79-
to: `https://npm.chart.dev/${module.npm}`,
91+
to: `https://npm.chart.dev/${props.module.npm}`,
8092
target: '_blank'
8193
}
8294
]
@@ -112,15 +124,15 @@ const items = computed(() => [
112124
</template>
113125

114126
<UBadge
115-
v-if="showBadge && module.type === 'official'"
127+
v-show="showBadge && module.type === 'official'"
116128
class="shine absolute top-4 right-4 sm:top-6 sm:right-6"
117129
variant="subtle"
118130
color="primary"
119131
label="Official"
120132
/>
121133

122134
<UBadge
123-
v-if="showBadge && module.sponsor"
135+
v-show="showBadge && module.sponsor"
124136
class="shine absolute top-4 right-4 sm:top-6 sm:right-6"
125137
variant="subtle"
126138
color="important"
@@ -161,7 +173,14 @@ const items = computed(() => [
161173
target="_blank"
162174
>
163175
<UIcon name="i-lucide-radio" class="size-4 shrink-0" />
164-
<span class="text-sm font-medium whitespace-normal">{{ date }}</span>
176+
<span class="text-sm font-medium whitespace-normal">
177+
<ClientOnly>
178+
{{ relativeDate }}
179+
<template #fallback>
180+
{{ staticModuleDate }}
181+
</template>
182+
</ClientOnly>
183+
</span>
165184
</NuxtLink>
166185
</UTooltip>
167186

@@ -172,7 +191,14 @@ const items = computed(() => [
172191
target="_blank"
173192
>
174193
<UIcon name="i-lucide-package" class="size-4 shrink-0" />
175-
<span class="text-sm font-medium whitespace-normal">{{ date }}</span>
194+
<span class="text-sm font-medium whitespace-normal">
195+
<ClientOnly>
196+
{{ relativeDate }}
197+
<template #fallback>
198+
{{ staticModuleDate }}
199+
</template>
200+
</ClientOnly>
201+
</span>
176202
</NuxtLink>
177203
</UTooltip>
178204
</div>

app/pages/modules/index.vue

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ defineShortcuts({
4747
}
4848
})
4949
50-
const breakpoints = useBreakpoints({
51-
sm: 640,
52-
md: 768,
53-
lg: 1024
54-
}, { ssrWidth: 1024 })
55-
56-
const isMobile = breakpoints.smaller('sm')
57-
5850
const ITEMS_PER_PAGE = 9
5951
const SCROLL_THRESHOLD = 450
6052
const displayedModules = ref<Module[]>([])
@@ -143,7 +135,9 @@ initializeModules()
143135

144136
<template>
145137
<UContainer ref="el">
146-
<LazyModulesMarquee :modules="modules" />
138+
<ClientOnly>
139+
<LazyModulesMarquee :modules="modules" />
140+
</ClientOnly>
147141

148142
<UPageHero
149143
class="z-20 relative pt-24"
@@ -189,7 +183,7 @@ initializeModules()
189183
</template>
190184
</UInput>
191185

192-
<div v-if="!isMobile" class="flex gap-2 sm:w-auto">
186+
<div class="hidden sm:flex gap-2 sm:w-auto">
193187
<USelectMenu
194188
:model-value="selectedSort"
195189
:items="sorts"
@@ -212,7 +206,7 @@ initializeModules()
212206
</div>
213207
</div>
214208

215-
<div v-if="isMobile" class="flex gap-2">
209+
<div class="flex sm:hidden gap-2">
216210
<USelectMenu
217211
:model-value="selectedCategory"
218212
:items="categories"

nuxt.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default defineNuxtConfig({
117117
'/docs/3.x/getting-started/introduction': { prerender: true },
118118
'/docs/4.x/getting-started/introduction': { prerender: true },
119119
'/docs/5.x/getting-started/introduction': { prerender: true },
120-
'/modules': { prerender: true },
120+
'/modules': { isr: false, prerender: false },
121121
'/modules/**': { isr: 60 * 60 },
122122
'/changelog': { isr: 60 * 60 },
123123
// API
@@ -413,7 +413,7 @@ export default defineNuxtConfig({
413413
prerender: {
414414
crawlLinks: true,
415415
ignore: [
416-
route => route.startsWith('/modules/'),
416+
route => route === '/modules' || route.startsWith('/modules/'),
417417
route => route.startsWith('/admin')
418418
],
419419
autoSubfolderIndex: false

0 commit comments

Comments
 (0)