refactor: Nuxt best practices and clean code review#14
Merged
Conversation
- Remove unnecessary explicit imports (leverage Nuxt auto-imports for utils and components) - Extract duplicate getTimestamp into shared utils/date.ts - Fix dead conditional in TalkPreviewCard (identical branches) - Fix non-null assertion mixed with optional chaining in Hero.vue - Extract repeated Motion animation config into constants in Hero.vue - Add error handling to clipboard utility - Replace raw <img> with <NuxtImg> for image optimization - Use stable keys instead of array index in v-for loops - Add build validation step to CI workflow https://claude.ai/code/session_01D9Js2socgpErtmsWh88fMj
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comprehensive Code Review: Nuxt Rewrite
Overall the rewrite is solid — good use of Nuxt 4, @nuxt/content collections with Zod validation, Nuxt UI, and static generation. Below is the full review with findings categorized by severity, followed by what this PR fixes.
What this PR fixes
utils/andcomponents/. Removed 10+ manual imports across pages and components that were redundant.getTimestampintoutils/date.ts— Bothlabs.tsandspeaking.tshad their own copy with slightly different signatures. Unified into a single shared utility.TalkPreviewCard.vue—:uibody padding wasvariant === 'featured' ? 'p-6 sm:p-8' : 'p-6 sm:p-8'(identical branches).Hero.vue—global.picture?.alt!is contradictory; replaced with?? 'Profile picture'fallback.Hero.vue— The same 6-line animation object was duplicated 5 times. Extracted intoheroInitial,heroAnimate, andheroTransition()constants.clipboard.ts—navigator.clipboard.writeText()can fail (permissions, insecure context) but the rejection was unhandled.<img>with<NuxtImg>— Inlabs/[slug].vue, a plain<img>tag bypassed the@nuxt/imageoptimization pipeline.v-forloops —AppFooter.vueandHero.vueused array index as:key; replaced witharia-labelortofor stable identity.pnpm run generatestep.Additional review findings (not addressed in this PR)
These are observations for future consideration:
better-sqlite3in dependencies but unused@vueuse/nuxtimported but onlyuseColorModeappears used (already in Nuxt UI)flatted,h3,socket.io-parserhave no comments[slug].vuepages fetch ALL entries then filter client-sidenuxt-og-imagemodule installed butdefineOgImage()never calleduseSeoMetapattern across all pagesusePageSeocomposablecompatibilityDate: '2024-11-01'is outdated for Nuxt 4LabsSectionandSpeakingSectiontypes in teaser components duplicate the content schema button typedangerous-clean-slate: true@typescript-eslint/no-explicit-any: 'off'globally disabledWhat's done well
crawlLinksfor automatic route discovery<ClientOnly>usage for the color mode buttonTest plan
pnpm run lintpassespnpm run typecheckpassespnpm run generatebuilds successfullyhttps://claude.ai/code/session_01D9Js2socgpErtmsWh88fMj