fix: support structured user variables#1488
Conversation
eaglethrost
left a comment
There was a problem hiding this comment.
Have some comments on this!
| interface Variables { | ||
| defaults: { default: string; name: string }[]; | ||
| user: Record<string, string>; | ||
| user: Record<string, unknown>; |
There was a problem hiding this comment.
This change makes sense but just be careful since this type gets used in several places including the main readme repo 🙏 Hopefully it doesn't break
There was a problem hiding this comment.
yea good point - funny enough it looks like the readme repo imports Variables from packages/iso/src/types/rdmd.ts and not directly from this package, and that type already declares user: Record<string, unknown>. So widening here brings @readme/markdown in line with what readme repo already expects.
At least to my understanding, the only direct consumer that needed updating is mdx-renderer (handled in my other pr)
| describe('render mdxish variables', () => { | ||
| it.each([ | ||
| { | ||
| expected: '[{"apiKey":"rdme_123"}]', |
There was a problem hiding this comment.
mdxish resolves {user.*} as whole variable nodes rather than arbitrary JS expressions, so these cases assert the stringified value instead of drilling into nested properties like mdx.
0fdeb33 to
f5be555
Compare
0fdeb33 to
2685cb9
Compare
2685cb9 to
0fdeb33
Compare
🎯 What does this PR do?
variables.usersupports structured values, not only strings.user.keyscan be an array of key objects.@readme/markdowntypes. See that PR or the ticket for more context.🧪 QA tips
📸 Screenshot or Loom
N/A, renderer/type behavior only.