Hashtags: turn #tags in posts into search links

Aperta
#121 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend, search

Direzione di ricerca

Start with the link splitter in packages/shared/src/links.ts, then the renderer in apps/web/src/components/RichText.tsx. Add a hashtag part type that skips # inside URL fragments, C# and a#b, and render it as a router link to /search?q=%23tag. Check apps/api/src/controllers/searchController.ts to confirm #tag is matched as a word. Done when the unit tests for the edge cases pass and npm test is green.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement help wanted shared web

Difficulty: Intermediate · Estimated size: 1 day

Context

Posts are plain text. Links are already made clickable by splitLinks in packages/shared/src/links.ts and rendered by apps/web/src/components/RichText.tsx.

Problem or goal

Words such as #opensource should look like links and open the search page for that tag, so people can find related posts.

Suggested approach

  • Extend the text splitter with a hashtag part type: # followed by 2 to 50 letters, numbers or underscores, not inside a link and not part of a word (C# and a#b are not tags).
  • Render it in RichText as a router Link to /search?q=%23tag.
  • Make sure the search endpoint treats #tag as a word match (check apps/api/src/controllers/searchController.ts).
  • Add unit tests next to the existing links.test.ts.

Where to look

  • packages/shared/src/links.ts
  • apps/web/src/components/RichText.tsx
  • apps/api/src/tests/links.test.ts
  • apps/web/src/pages/SearchPage.tsx

Acceptance criteria

  • #tag is a link in the feed, Explore, post page and comments.
  • URLs containing # fragments (https://a.com/x#top) are still one link, not a link plus a tag.
  • Tags never become HTML.
  • Tests cover edge cases: start of text, punctuation after the tag, numbers only, unicode letters, very long tags.

Out of scope

Trending tags and tag pages.

How to work on it

  1. Comment here to claim it, so two people do not do the same work.
  2. Fork the repo and branch from main (feat/short-name or fix/short-name). Setup steps are in docs/DEVELOPMENT.md.
  3. Keep the change focused and add tests for backend logic.
  4. Run npm run typecheck, npm test and npm run lint and npm run format before opening the pull request.
  5. Use a Conventional Commits title (for example feat(web): add bookmarks). More in CONTRIBUTING.md.

Stuck? Ask in this issue. Questions are welcome.


Generated by Claude Code

Lingua principale
TypeScript
Stelle
6
Fork
6
Merge medio
1h 59m
PR unite (30g)
59

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Haseeb-MernStack/commune

Tutte le issue di Haseeb-MernStack/commune

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.