tailwindlabs / tailwindcss.com

The Tailwind CSS documentation website.
https://tailwindcss.com
3.25k stars 1.72k forks source link

Adds support to multiple frameworks on code blocks #1853

Closed miguel-arrf closed 1 month ago

miguel-arrf commented 1 month ago

Hi!

This is a work in progress since the way I am handling different frameworks might not yet be optimal and could be clearer, specifically in the way I'm changing the getStaticProps function. Right now, I want to understand if this feature is even useful.

Motivation:

Some websites (e.g., nuxt.com) have code blocks similar to those found on tailwindcss.com, but with the option to select different frameworks (e.g., npm, yarn, pnpm, bun) instead of just npm.

Design:

New button (displayed only when the code block has different framework configurations):

unselected-state

Different framework selected (bun ➜ npm):

changed-state

No changes if a code block doesn't have a specified framework:

one-has-other-doesnt-sate

Usage:

Before:

code: {
  name: 'Terminal',
  lang: 'terminal',
  code: 'npx nuxi init my-project\ncd my-project',
},

After:

code: {
  name: 'Terminal',
  lang: 'terminal',
  frameworks: [
    {
      name: 'npm',
      code: 'npx nuxi init my-project\ncd my-project',
    },
    {
      name: 'bun',
      code: 'bunx nuxi init my-project\ncd my-project',
    },
  ],
},

If you do not want to add more frameworks for a specific block, no changes are needed!

Changes:

This Pull Request adds:

[!WARNING]
I only updated the nuxtjs.js page to test things out. If this Pull Request moves forward, I can either update no page (and just add the new logic) or update all relevant pages.

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tailwindcss-com ❌ Failed (Inspect) Aug 5, 2024 0:02am
adamwathan commented 1 month ago

Hey thanks for the PR! I hate to do this but going to say no to this one for now because I don't want to take on the overhead of maintaining a bunch of instructions for npm alternatives 😕 Going to just roll with the assumption that anyone who is in the loop enough to use bun or pnpm instead of npm understands npm commands and knows how to translate those instructions for their alternate package manager.

Thanks regardless 🤝🏻