Commit Graph

4 Commits

Author SHA1 Message Date
Ivan Vasilov 70388e50bb fix: Use amaro for stripping types in code samples (#41229)
* Fix the error for babel/preset-typescript in docs.

* Unfix the version.

* Try using amaro for type stripping.

* Run prettier after stripping types.

* Fix tests.

---------

Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
2025-12-10 16:23:46 +01:00
Charis ef93da79b0 feat(docs): code samples with ts type stripping (#37695)
* feat(docs): code samples with ts type stripping

Introduce a new option to `$CodeSample`, `convertToJs`, which takes a
code sample written in TypeScript and strips the types to produce a
JavaScript version.

Adds tests for type stripping.

* Clarify instructions

---------

Co-authored-by: Chris Chinchilla <chris@chrischinchilla.com>
2025-08-06 10:21:51 -04:00
Charis c0f7cc0f99 fix(docs): external code sample on local dev (#30854)
Pages incorporating an external code sample on local dev will fail for contributors without the GitHub API key. This PR fixes the local DX by replacing such code samples with a local-only message describing the error, and asking contributors to check the preview site.
2024-12-05 15:51:03 -05:00
Charis c2fe11850d feat: embed code samples from github (#29519)
Add the ability to embed code samples from GitHub into tutorials, so we can have a single source of truth for the source code.

Introduces the <$CodeSample /> syntax, which is a special syntax and not a real React component (see the directives/README.md for why on earth I did it this way -- in this specific case, CodeHike adjusts the MDX syntax tree before it gets compiled, and we need to adjust it ourselves before CodeHike sees it, so we need to get down to the level of manipulating the AST in order to make this work with CodeHike).

Adjusted one of the example tutorials to use this new feature as a test.
2024-09-26 15:54:57 -04:00