Repository navigation
docs(useLinkify): add hook docs and a comment-thread example block - #9969
Conversation
A HookDoc next to the hook source (usage, text and options params covering patterns/hasBuiltins, the ReactNode[] return, best practices), so astryx hook useLinkify and astryx search return it, and a template block naming useLinkify in exampleFor: the issue's scenario, a short comment thread in plain text where the URL and the email address become Links and a custom issue-reference pattern turns meta#123/meta#456 into tracker links, while a comment without matches stays plain. Removing the hook call removes every link, per INV28. A jsdom test asserts the four hrefs (url, mailto, two issue links) and that the plain note renders no anchor. Closes meta#9560
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Hi @LetMeSleep8h! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Changes requested: the hook doc and the comment-thread example fit #9560 well, but four things need fixing before this can merge.
- The docs build fails:
node apps/docsite/scripts/generate-data.mjsstops with "Generated ShadCN names or routes changed" becauseinternal/shadcn-registry/routes.lock.jsonhas nohook-use-linkifyandexample-use-linkify-links-in-a-comment-threadentries, so refresh it withUPDATE_SHADCN_ROUTE_LOCK=1 node apps/docsite/scripts/generate-data.mjsand commit the two new items. apps/sandbox/src/route-manifest.test.tsfails becauseapps/sandbox/scripts/next-export-routes.jsonis missing"/templates/useLinkifyHookUsage/", which belongs between theuseKeyboardHintHookUsageanduseListFocusHookUsagelines..changeset/hook-doc-use-linkify.mdlacks its opening---line and a contributor credit line such as@LetMeSleep8h, sopnpm check:changesetsfails.- The best practice at
packages/core/src/Link/useLinkify.doc.mjs:75says a non-global regex "matches nothing", but withoutgthe hook's scan never advances and the render hangs when the text contains a match, so the doc should say that.
Two smaller points: the overlap wording ("custom before builtins") should say that the earliest match wins and that custom patterns win only at the same start, and the No links here assertion in the test can never fail. #9719 shows the route-list and route-lock lines that a new hook doc and example need.
[Automated review]
… global-flag and overlap wording Adds the hook doc and example to the ShadCN route lock and the sandbox export routes, gives the changeset its frontmatter and contributor credit, says a non-global pattern never finishes rendering when the text matches, and says the earliest match wins with custom patterns winning only at the same start. Drops a test assertion that could never fail.
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| LinkProvider | 3.6 kB (0) · 20 B CSS (0) | — | ✓ · ✓ · ✗ |
| Link | 53.2 kB (0) · 7.0 kB CSS (0) | — | ✓ · ✓ · — |
Package size:
- @astryxdesign/cli 3.52 MB packed (+579 B); no new dependencies
- @astryxdesign/core 7.20 MB packed (+1.2 kB); no new dependencies
API changes: none in this pull request
Committed API report behind this build: cli 29 rows, core 34 rows, theme-butter 1 row, theme-y2k 1 row; run pnpm api:report.
Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet.
The hook doc and the comment-thread example now meet the repository's requirements for public hook docs, and the four points from the earlier review are fixed: the route-lock and sandbox route entries are in, the changeset passes its check, and the global-flag best practice now says a non-global pattern never finishes rendering.
- Next step: the
ci:runlabel is already on the pull request, and it takes effect on the next push or when a maintainer closes and reopens the pull request, so CI runs on this head.
One optional, non-blocking suggestion is inline.
[Automated review]
| }, | ||
| relatedComponents: ['Link', 'LinkProvider'], | ||
| importPath: '@astryxdesign/core', | ||
| category: 'link', |
There was a problem hiding this comment.
Non-blocking, and missed in the earlier review: category: 'link' gives astryx hook --list a one-entry "Link" heading, while the sibling useLinkComponent is listed under "Utilities", so astryx hook --category Utilities returns one Link hook but not the other. Consider category: 'utilities'.
The recorded resolution for useLinkify moves from Link.doc.mjs to the new useLinkify.doc.mjs, as other hook-doc additions have done.
There was a problem hiding this comment.
Approved: the hook doc and the comment-thread example meet the repository's requirements for public hook docs, and CI passes on this head.
The new commit updates the CLI's recorded resolution for useLinkify, which its resolution test needs.
- The CLA check still needs your signature before this pull request can merge.
The earlier optional suggestion about the hook's category still stands inline.
[Automated review]
Closes #9560
What
packages/core/src/Link/useLinkify.doc.mjs— HookDoc foruseLinkify: usage, thetextandoptionsparams (patternswith its global-regex requirement and first-match-wins overlap rule,hasBuiltins), theReactNode[]return, and best practices (render nodes as-is, LinkProvider for client-side routing, /g flag on custom patterns).astryx hook useLinkifyandastryx searchnow return it.Link/useLinkifyHookUsage.tsx+.doc.mjs— the issue's scenario: a short comment thread in plain text where the hook turns the URL and the email into Links, and a custom#(\\d+)issue pattern maps the capture onto the tracker URL scheme (#123→https://example.com/issues/123), showing thepatternsoption; the comment without matches stays plain text.exampleFor: 'useLinkify'; public entry points only; removing the hook call removes every link (INV28).packages/cli/api/template/use-linkify-hook-usage.test.tsx— jsdom test asserting the four rendered hrefs (external URL,mailto:, two issue links) and zero anchors for the plain note.Verification (run locally)
AI-assisted (Claude): written with AI assistance, reviewed and verified locally — every command above was actually run.