import { useState } from 'react'; const STEPS = [ { title: '1. Create a Hugging Face Account', content: `Go to huggingface.co and sign up for a free account (if you don't have one already).`, link: 'https://huggingface.co/join', linkText: 'Sign up at huggingface.co', }, { title: '2. Create a New Space', content: `Click "New Space" from your profile. Give it a name like "subtitle-translator". For the SDK, choose "Static" (this is a pre-built static site). Set visibility to "Public" (free tier).`, link: 'https://huggingface.co/new-space', linkText: 'Create New Space →', }, { title: '3. Clone the Space Repository', content: `Open a terminal and clone your new Space: git clone https://huggingface.co/spaces/YOUR_USERNAME/subtitle-translator cd subtitle-translator`, code: `git clone https://huggingface.co/spaces/YOUR_USERNAME/subtitle-translator cd subtitle-translator`, }, { title: '4. Build this Project Locally', content: `Make sure you have Node.js installed. Then build the project: npm install npm run build This creates a "dist/" folder with the static files.`, code: `npm install npm run build`, }, { title: '5. Copy Build Files to Space', content: `Copy all files from the "dist/" folder into the cloned Space folder: cp -r dist/* /path/to/subtitle-translator/ Your Space folder should now have: index.html, assets/, etc.`, code: `# On Mac/Linux: cp -r dist/* ./subtitle-translator/ # On Windows: xcopy dist\\* subtitle-translator\\ /E /Y`, }, { title: '6. Push to Hugging Face', content: `Navigate into the Space folder and push: cd subtitle-translator git add . git commit -m "Deploy subtitle translator" git push Your app will be live at: https://huggingface.co/spaces/YOUR_USERNAME/subtitle-translator`, code: `cd subtitle-translator git add . git commit -m "Deploy subtitle translator" git push`, }, ]; const DOCKER_README = `--- title: SubTranslate - Subtitle Translator emoji: 🌍 colorFrom: purple colorTo: pink sdk: static pinned: false ---`; export function DeployGuide({ onClose }: { onClose: () => void }) { const [copiedIdx, setCopiedIdx] = useState(null); const [activeTab, setActiveTab] = useState<'static' | 'docker'>('static'); const copyToClipboard = (text: string, idx: number) => { navigator.clipboard.writeText(text); setCopiedIdx(idx); setTimeout(() => setCopiedIdx(null), 2000); }; return (
{/* Backdrop */}
{/* Modal */}
{/* Header */}
🤗

Deploy to Hugging Face Spaces

Host your subtitle translator for free

{/* Tabs */}
{/* Content */}
{activeTab === 'static' && ( <>

✨ Recommended: The Static SDK is the simplest way to deploy. It serves your built HTML/CSS/JS files directly — no server needed.

{STEPS.map((step, idx) => (

{step.title}

{step.content}

{step.code && (
                          {step.code}
                        
)} {step.link && ( {step.linkText} )}
))} )} {activeTab === 'docker' && ( <>

🐳 Docker: For advanced users. This uses a Dockerfile to build and serve the app inside a container on Hugging Face Spaces.

1. Create Space with Docker SDK

Create a new Space and select "Docker" as the SDK.

Create New Space →

2. Add README.md (Space metadata)

Create a README.md in your Space root:

                      {DOCKER_README}
                    

3. Add Dockerfile

Create a Dockerfile:

{`# Build stage
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Production stage
FROM nginx:alpine
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 7860
CMD ["nginx", "-g", "daemon off;"]

# ⚠️ IMPORTANT: Also add nginx.conf file:
# server {
#     listen 7860;
#     server_name _;
#     root /usr/share/nginx/html;
#     index index.html;
#     location / {
#         try_files $uri $uri/ /index.html;
#     }
# }`}
                    

4. Push all project files

Push ALL project files (src/, package.json, etc.) along with the Dockerfile and README.md:

{`git add .
git commit -m "Deploy subtitle translator"
git push`}
                    

Hugging Face will automatically build the Docker image and deploy your app! 🎉

)} {/* Quick alternative */}

⚡ Quickest Method: Upload via Browser

  1. Go to{' '} huggingface.co/new-space
  2. Select "Static" SDK, name your space
  3. Go to Files → Add file → Upload files
  4. Upload the contents of the dist/ folder (index.html + assets/)
  5. Your app goes live instantly! 🚀
{/* Footer */}
); }