Skip to content

MayankBansal12/shift-read

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Shift

Read any article on the internet in your preferred language. Shift extracts article content from web pages and translates it while preserving formatting, images, and typography.

โœจ Features

  • ๐Ÿ•ท๏ธ Web Scraping: Extract clean article content from any URL using Firecrawl
  • ๐ŸŒ Translation: Translate articles to 12+ languages while preserving Markdown formatting
  • ๐Ÿ’พ Smart Caching: Articles and translations are cached locally for instant re-access
  • ๐ŸŽจ Beautiful Reading: Clean, minimal reader mode with typography optimized for long-form content
  • ๐ŸŒ“ Dark Mode: Toggle between light and dark themes
  • ๐Ÿ“ฑ Responsive Design: Works perfectly on mobile, tablet, and desktop
  • โšก Instant Loading: Cached articles load instantly on revisit
  • ๐Ÿ”„ Language Toggle: Seamlessly switch between original and translated content

๐Ÿ›  Tech Stack

  • Framework: Next.js 16.1.4 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS 4 (built-in typography support)
  • UI Components: shadcn/ui (base-nova style, hugeicons)
  • Web Scraping: @mendable/firecrawl-js
  • Translation: lingo.dev SDK
  • Markdown Rendering: react-markdown with remark-gfm and rehype-highlight
  • Syntax Highlighting: react-syntax-highlighter
  • Caching: localStorage with timestamp-based cache management

๐Ÿš€ What lingo.dev Feature It Highlights

Shift showcases lingo.dev's Markdown translation capabilities. The app demonstrates how lingo.dev can:

  • Translate complex Markdown content while preserving formatting
  • Handle code blocks, links, images, and rich text structure
  • Maintain document structure during translation
  • Provide seamless language switching for content-heavy applications

The translation preserves:

  • Headers and text hierarchy
  • Code blocks with syntax highlighting
  • Image references and alt text
  • Links and their targets
  • Lists, quotes, and other Markdown elements

๐Ÿ“ฆ Installation

Prerequisites

  • Node.js 18+
  • pnpm (recommended) or npm/yarn

Setup

  1. Clone the repository

    git clone <repository-url>
    cd shift-read
  2. Install dependencies

    pnpm install
  3. Set up environment variables

    Create a .env.local file in the project root:

    FIRECRAWL_API_KEY=your_firecrawl_api_key_here
    LINGODOTDEV_API_KEY=your_lingodotdev_api_key_here
  4. Get API Keys

  5. Run the development server

    pnpm dev
  6. Open your browser Navigate to http://localhost:3000

๐Ÿƒโ€โ™‚๏ธ Running Locally

Development Mode

pnpm dev

Starts the development server with hot reload at http://localhost:3000

Build for Production

pnpm build

Creates an optimized production build

Start Production Server

pnpm start

Runs the production build at http://localhost:3000

Linting

pnpm lint

Runs ESLint to check for code issues

๐ŸŒ Supported Languages

Shift supports translation to these languages:

  • ๐Ÿ‡ช๐Ÿ‡ธ Spanish (es)
  • ๐Ÿ‡ซ๐Ÿ‡ท French (fr)
  • ๐Ÿ‡ฉ๐Ÿ‡ช German (de)
  • ๐Ÿ‡ฏ๐Ÿ‡ต Japanese (ja)
  • ๐Ÿ‡จ๐Ÿ‡ณ Chinese (zh)
  • ๐Ÿ‡ธ๐Ÿ‡ฆ Arabic (ar)
  • ๐Ÿ‡ฎ๐Ÿ‡ณ Hindi (hi)
  • ๐Ÿ‡ต๐Ÿ‡น Portuguese (pt)
  • ๐Ÿ‡ท๐Ÿ‡บ Russian (ru)
  • ๐Ÿ‡ฐ๐Ÿ‡ท Korean (ko)
  • ๐Ÿ‡ฎ๐Ÿ‡น Italian (it)
  • ๐Ÿ‡ณ๐Ÿ‡ฑ Dutch (nl)

The source language is automatically detected and filtered from the translation options.

๐Ÿ“‚ Project Structure

shift-read/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ page.tsx                    # Homepage with URL input
โ”‚   โ”œโ”€โ”€ layout.tsx                  # Root layout with providers
โ”‚   โ”œโ”€โ”€ globals.css                 # Global styles (Tailwind v4)
โ”‚   โ”œโ”€โ”€ read/[...url]/
โ”‚   โ”‚   โ””โ”€โ”€ page.tsx               # Reading page with article display
โ”‚   โ””โ”€โ”€ actions/
โ”‚       โ”œโ”€โ”€ fetchContent.ts        # Firecrawl server action
โ”‚       โ”œโ”€โ”€ translate.ts           # lingo.dev server action
โ”‚       โ””โ”€โ”€ cleanMarkdown.ts       # Markdown cleanup utilities
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ ArticleHeader.tsx          # Title, author, date, image display
โ”‚   โ”œโ”€โ”€ LanguageSelector.tsx       # Language dropdown
โ”‚   โ”œโ”€โ”€ MDXRender.tsx              # Markdown renderer with custom components
โ”‚   โ””โ”€โ”€ ThemeToggle.tsx            # Dark/light mode toggle
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ utils.ts                   # Utility functions
โ”‚   โ””โ”€โ”€ storage.ts                 # localStorage helpers
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ next.config.ts
โ””โ”€โ”€ tsconfig.json

๐ŸŽฏ How It Works

  1. URL Input: User enters an article URL on the homepage
  2. Content Extraction: Firecrawl scrapes the URL and extracts clean Markdown content
  3. Caching: Article is cached in localStorage for instant future access
  4. Translation: User can select a target language and lingo.dev translates the content
  5. Display: Article is rendered with beautiful typography and preserved formatting
  6. Toggle: Users can switch between original and translated content seamlessly

๐Ÿงช Testing

Manual Testing Checklist

  • Homepage: URL validation, navigation, theme toggle
  • Content Extraction: Test with Medium, Substack, personal blogs
  • Translation: Verify language selection and translation quality
  • Caching: Confirm instant loading of cached articles
  • Responsive: Test on mobile, tablet, desktop
  • Dark Mode: Verify all components work in both themes

Test URLs

# Medium articles
https://medium.com/@author/article-title

# Substack articles  
https://author.substack.com/p/article-title

# Personal blogs
https://example.com/blog/article-title

๐Ÿ”ง Configuration

Next.js Configuration

The next.config.ts file allows external images from any HTTPS domain:

images: {
  remotePatterns: [
    {
      protocol: 'https',
      hostname: '**',
    },
  ],
}

Environment Variables

Required environment variables:

FIRECRAWL_API_KEY=    # Firecrawl API key for web scraping
LINGODOTDEV_API_KEY=  # lingo.dev API key for translation

๐Ÿ› Troubleshooting

Common Issues

Issue: "Failed to extract article content"

  • Solution: Check Firecrawl API key and ensure URL is accessible

Issue: "Translation failed"

  • Solution: Verify lingo.dev API key and target language code

Issue: Images not loading

  • Solution: Ensure images are served over HTTPS (Next.js requirement)

Issue: Styling issues

  • Solution: Clear browser cache and restart dev server

Debug Mode

Add debug logging by setting:

DEBUG=shift:*

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“ž Support

If you have any questions or issues, please open an issue on the GitHub repository.


Built with โค๏ธ using Next.js, Tailwind CSS, Firecrawl, and lingo.dev

About

Read any article on the internet in your own language

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors