marshalImportInputValue serializes an import input value to a string suitable for substitution into both YAML frontmatter and markdown prose. Arrays and maps are serialized as JSON (which is valid YAML inline syntax). Scalar values use Go's default string formatting. goccy/go-yaml may produce typed
(value any)
| 519 | // goccy/go-yaml may produce typed slices (e.g. []string) instead of []any, so |
| 520 | // a reflection fallback converts any slice kind to []any before JSON marshaling. |
| 521 | func marshalImportInputValue(value any) string { |
| 522 | if formatted, ok := importinpututil.FormatResolvedValue(value); ok { |
| 523 | return formatted |
| 524 | } |
| 525 | if value == nil { |
| 526 | // Null import input — return empty string rather than panicking. |
| 527 | return "" |
| 528 | } |
| 529 | return fmt.Sprintf("%v", value) |
| 530 | } |
| 531 | |
| 532 | // resolveImportInputPath resolves a potentially dotted key path from the importInputs map. |
| 533 | // For scalar inputs ("count"), it looks up importInputs["count"] directly. |