fix: locale aware build time in footer#1300
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughThe BuildEnvironment component has been refactored to change how the build time is displayed. The locale variable reference from i18n has been removed. A new computed property buildTime has been introduced, extracting the time value from buildInfo. The NuxtTime component has been replaced with a DateTime component, which receives the buildTime along with explicit formatting options for year, month, and day. The template has been updated accordingly to utilise the new DateTime component for the built_at display. 🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/components/BuildEnvironment.vue (1)
10-21:⚠️ Potential issue | 🟠 MajorGuard against missing buildInfo/time to avoid runtime crashes.
If both the prop and
appConfig.buildInfoare absent (ortimeis missing),buildInfo.value.timewill throw and DateTime may render an invalid date. Add a null-guard and only render when a valid time exists.Proposed fix
-const buildTime = computed(() => new Date(buildInfo.value.time)) +const buildTime = computed(() => { + const time = buildInfo.value?.time + return time ? new Date(time) : null +})- <i18n-t keypath="built_at" scope="global"> - <DateTime :datetime="buildTime" year="numeric" month="short" day="numeric" /> - </i18n-t> + <i18n-t keypath="built_at" scope="global"> + <DateTime + v-if="buildTime" + :datetime="buildTime" + year="numeric" + month="short" + day="numeric" + /> + </i18n-t>As per coding guidelines: “Ensure you write strictly type-safe code, for example by ensuring you always check when accessing an array value by index”.
| const { locale } = useI18n() | ||
| const appConfig = useAppConfig() | ||
| const buildInfo = computed(() => buildInfoProp || appConfig.buildInfo) | ||
| const buildTime = computed(() => new Date(buildInfo.value.time)) |
There was a problem hiding this comment.
I don't think this is necessary - you should just be able to pass buildInfo.time into <DateTime>
Before

After:
