Skip to content

Commit fe667bf

Browse files
committed
Move component prop interfaces to SFC <script> blocks
@vue/compiler-sfc cannot resolve Nuxt auto-imported types in defineProps<T>() during production builds. Move GoPkgProps to go-pkg.vue and ProseHeadingProps to prose-heading.vue so the compiler finds them in the file's own scope. GoPkgLink stays in app/utils/go-pkg.ts as the return type of resolveGoPkg. Signed-off-by: Alejandro Mery <amery@apptly.co>
1 parent 37fba9b commit fe667bf

7 files changed

Lines changed: 43 additions & 24 deletions

File tree

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ Logging uses `consola` with tagged instances (`badge:go`,
117117

118118
### Components
119119

120+
Types used in `defineProps<T>()` must be defined or imported
121+
in the component's `<script>` block — auto-imports are not
122+
resolved during production builds.
123+
120124
- `BadgeVersion` — generic badge `<img>` wrapper with loading
121125
skeleton, error fallback (shows alt text), and SSR hydration
122126
handling (`onMounted` checks `complete` + `naturalWidth`).

app/components/content/prose-h2.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script lang="ts">
2+
import type { ProseHeadingProps } from './prose-heading.vue';
3+
</script>
4+
15
<script setup lang="ts">
26
/** Prose h2 override — delegates to ProseHeading with anchor glyph. */
37
const props = defineProps<ProseHeadingProps>();

app/components/content/prose-h3.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script lang="ts">
2+
import type { ProseHeadingProps } from './prose-heading.vue';
3+
</script>
4+
15
<script setup lang="ts">
26
/** Prose h3 override — delegates to ProseHeading with anchor glyph. */
37
const props = defineProps<ProseHeadingProps>();

app/components/content/prose-heading.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
<script lang="ts">
2+
/** Shared props for prose heading overrides. */
3+
export interface ProseHeadingProps {
4+
/** Heading anchor ID, used for the `id` attribute and `#` permalink. */
5+
id?: string
6+
/** Anchor glyph shown on hover. */
7+
glyph?: string
8+
}
9+
</script>
10+
111
<script setup lang="ts">
212
/** Generic prose heading with hover-visible anchor glyph. */
313
const props = withDefaults(defineProps<ProseHeadingProps & {
414
/** HTML heading element to render. */
515
as: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
616
}>(), {
17+
id: undefined,
718
glyph: '\u00A7',
819
});
920
</script>

app/components/go-pkg.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
<script lang="ts">
2+
/** Props accepted by the `:go-pkg` MDC component. */
3+
export interface GoPkgProps {
4+
/** Go module path (e.g. `darvaza.org/resolver`). */
5+
mod: string
6+
/** Subdirectory within the module (e.g. `pkg/client`). */
7+
dir?: string
8+
/** Type or constant name — links to `#Symbol`. */
9+
sym?: string
10+
/** Function name — links to `#Func`, label gets `()` suffix. Takes precedence over `sym`. */
11+
func?: string
12+
/** Show only the symbol/function name, omit the package prefix. Preserves `()` suffix for functions. */
13+
short?: boolean
14+
/** Override the display text. */
15+
label?: string
16+
}
17+
</script>
18+
119
<script setup lang="ts">
220
/** Inline link to pkg.go.dev with a trailing Go icon. */
321
const props = defineProps<GoPkgProps>();

app/utils/go-pkg.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
const BASE_URL = 'https://pkg.go.dev/';
1+
import type { GoPkgProps } from '~/components/go-pkg.vue';
22

3-
/** Props accepted by the `:go-pkg` MDC component. */
4-
export interface GoPkgProps {
5-
/** Go module path (e.g. `darvaza.org/resolver`). */
6-
mod: string
7-
/** Subdirectory within the module (e.g. `pkg/client`). */
8-
dir?: string
9-
/** Type or constant name — links to `#Symbol`. */
10-
sym?: string
11-
/** Function name — links to `#Func`, label gets `()` suffix. Takes precedence over `sym`. */
12-
func?: string
13-
/** Show only the symbol/function name, omit the package prefix. Preserves `()` suffix for functions. */
14-
short?: boolean
15-
/** Override the display text. */
16-
label?: string
17-
}
3+
const BASE_URL = 'https://pkg.go.dev/';
184

195
/** Resolved link data for a Go package reference. */
206
export interface GoPkgLink {

app/utils/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
// Virtual slug for the "Other" group (projects not under any umbrella).
22
export const OTHER_SLUG = '_';
33

4-
/** Shared props for prose heading overrides. */
5-
export interface ProseHeadingProps {
6-
/** Heading anchor ID, used for the `id` attribute and `#` permalink. */
7-
id?: string
8-
/** Anchor glyph shown on hover. */
9-
glyph?: string
10-
}
11-
124
/**
135
* Type-safe Array.includes that accepts a wider search value.
146
*

0 commit comments

Comments
 (0)