diff --git a/app/components/OgImage/BlogPost.vue b/app/components/OgImage/BlogPost.vue index 293979b1f2..555a0346df 100644 --- a/app/components/OgImage/BlogPost.vue +++ b/app/components/OgImage/BlogPost.vue @@ -15,18 +15,7 @@ const props = withDefaults( }, ) -const formattedDate = computed(() => { - if (!props.date) return '' - try { - return new Date(props.date).toLocaleDateString('en-US', { - year: 'numeric', - month: 'short', - day: 'numeric', - }) - } catch { - return props.date - } -}) +const formattedDate = computed(() => formatDate(props.date)) const MAX_VISIBLE_AUTHORS = 2 diff --git a/app/components/OgImage/ShareCard.d.vue.ts b/app/components/OgImage/ShareCard.d.vue.ts new file mode 100644 index 0000000000..ccaeb99685 --- /dev/null +++ b/app/components/OgImage/ShareCard.d.vue.ts @@ -0,0 +1,17 @@ +// This type declaration file is required to break a circular type resolution in vue-tsc. +// And is based off Package.d.vue.ts +// +// nuxt-og-image generates a type declaration (.nuxt/module/nuxt-og-image.d.ts) that imports +// this component's type. This creates a cycle: nuxt.d.ts → nuxt-og-image.d.ts → ShareCard.vue → +// needs auto-import globals from nuxt.d.ts. Without this file, vue-tsc resolves the component +// before the globals are available, so all auto-imports (computed, toRefs, useFetch, etc.) fail. + +import type { DefineComponent } from 'vue' + +declare const _default: DefineComponent<{ + name: string + theme?: 'light' | 'dark' + color?: string +}> + +export default _default diff --git a/app/components/OgImage/ShareCard.vue b/app/components/OgImage/ShareCard.vue new file mode 100644 index 0000000000..e3ad2d85b2 --- /dev/null +++ b/app/components/OgImage/ShareCard.vue @@ -0,0 +1,331 @@ + + + diff --git a/app/components/Package/Header.vue b/app/components/Package/Header.vue index 318e9d82ae..df8f88bd9c 100644 --- a/app/components/Package/Header.vue +++ b/app/components/Package/Header.vue @@ -169,6 +169,8 @@ useShortcuts({ 'c': () => props.pkg && { name: 'compare' as const, query: { packages: props.pkg.name } }, 'f': () => diffLink.value, }) + +const shareModal = useModal('share-modal')