Skip to content

feat(plugin-third-parties): add rspress-plugin-third-parties 🎉 - #33

Merged
SoonIter merged 16 commits into
rstackjs:mainfrom
sanjaiyan-dev:sanjaiyan-third-party-plugins
Sep 24, 2026
Merged

SoonIter merged 16 commits into
rstackjs:mainfrom
sanjaiyan-dev:sanjaiyan-third-party-plugins

Conversation

@sanjaiyan-dev

@sanjaiyan-dev sanjaiyan-dev commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds rspress-plugin-third-parties to the official rspress-plugins monorepo under packages/rspress-plugin-third-parties.

Following up on the documentation PR (web-infra-dev/rspress#3546) and review from @SoonIter, this plugin brings optimized third-party component embeds and script loading strategies to the Rspress ecosystem.

👉 Live Interactive Playground: https://sanjaiyan-dev.github.io/rspress-plugin-third-parties


🚀 Key Features

  • Google Analytics (<GoogleAnalytics />): Lightweight GA4 script injection and event tracking.
  • Google Tag Manager (<GoogleTagManager />): Optimized GTM container initialization.
  • YouTube Embeds (<YouTubeEmbed />): Fast, accessible YouTube embeds using third-party-capital and React 19 resource preloading (ReactDOM.preconnect).
  • Twitter / X Embeds (<TweetEmbed />): Auto-detects Rspress dark/light mode themes and renders tweets via react-tweet.
  • Custom Script Strategy (<Script />): Flexible script loading strategies (beforeInteractive, afterInteractive, lazyOnload).

📦 Package Details

  • Location: packages/rspress-plugin-third-parties
  • Exports:
    • ".": Components (GoogleAnalytics, GoogleTagManager, YouTubeEmbed, TweetEmbed, Script)
    • "./plugin": Rspress Plugin Configuration (pluginThirdParties)
  • Documentation: Flattened into packages/rspress-plugin-third-parties/docs (pnpm docs:dev)

🧪 Testing & Verification

  • Unit & Browser Tests (rstest): 25 passed across 5 test suites (GoogleAnalytics, GoogleTagManager, Script, TweetEmbed, YoutubeEmbed).
  • Builds Cleanly (pnpm build): Dual ESM/CJS build generated via rslib.
  • Root README Updated: Listed under the ### Site category.
# Run tests inside the package
cd packages/rspress-plugin-third-parties
pnpm test

# Run demo locally
pnpm docs:dev

…mponents

- Implemented GoogleMapsEmbed component for embedding Google Maps with customizable options.
- Created GoogleTagManager component to facilitate Google Tag Manager integration with support for dataLayer and custom parameters.
- Developed YouTubeEmbed component for embedding YouTube videos with preconnect and script loading optimizations.
- Introduced ThirdPartyScriptEmbed component for rendering third-party scripts and HTML.
- Added TweetEmbed component for rendering tweets with theme support.
- Implemented Script component for optimized script loading strategies.
- Added utility functions for handling script attributes and idle callbacks.
- Created tests for all new components to ensure functionality and integration.
- Updated tsconfig for TypeScript support in the third-parties package.
- Updated import statements to use single quotes consistently.
- Reformatted code for better readability and consistency.
- Adjusted test descriptions for clarity and consistency.
- Ensured proper cleanup in tests to avoid side effects.
- Updated TypeScript configuration formatting for consistency.
Comment thread packages/rspress-plugin-third-parties/.vscode/settings.json Outdated
Comment thread packages/rspress-plugin-third-parties/docs/readme.mdx Outdated
@sanjaiyan-dev

Copy link
Copy Markdown
Contributor Author

Hi @SoonIter ,

I have resolved the pnpm-lock.yaml merge conflicts with upstream/main and pushed the updates. All builds and unit tests are passing cleanly.

Regarding the docs/ directory: I've kept the interactive playground hosted on my personal repository, and the files here are kept strictly for demo/test fixture purposes.

Could you please take another look and let me know if there's anything else needed before merge? Thanks :)

@SoonIter

Copy link
Copy Markdown
Member

This PR has been updated to use rstack-cli and @rstest/playwright, following the same tooling and E2E test setup as the other plugins in this repository.

@SoonIter

Copy link
Copy Markdown
Member

Hi @sanjaiyan-dev, could you please add my npm account sooniter as a maintainer of rspress-plugin-third-parties with publish access? This will let me include the package in the next release from this monorepo. Thanks!

@SoonIter
SoonIter merged commit 2a812cb into rstackjs:main Sep 24, 2026
2 checks passed
@sanjaiyan-dev

Copy link
Copy Markdown
Contributor Author

Hi @sanjaiyan-dev, could you please add my npm account sooniter as a maintainer of rspress-plugin-third-parties with publish access? This will let me include the package in the next release from this monorepo. Thanks!

Hi @SoonIter, I've added sooniter as a maintainer on npm with publish access. Thanks for merging and aligning the setup 🙏🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants