fetch-url-md
Fetch URL with Markdown Detection
Overview
Efficiently fetch web content by prioritizing markdown versions when available. Uses curl to check for .md versions first, then falls back to the original URL.
Workflow
Follow these steps sequentially:
1. Parse the original URL
Extract the base URL and path from the user-provided URL.
Example:
- Input:
https://ui.shadcn.com/docs/components/radix/aspect-ratio - Markdown URL:
https://ui.shadcn.com/docs/components/radix/aspect-ratio.md
2. Check for .md version
Use curl with HEAD request to check if .md version exists:
curl -sI "https://ui.shadcn.com/docs/components/radix/aspect-ratio.md" | head -n 1
- 200 OK - Markdown version exists, fetch it
- 404 Not Found - Markdown version doesn't exist, use original URL
- 3xx redirect - Follow the redirect or use original URL
3. Fetch content
If .md exists:
curl -s "https://ui.shadcn.com/docs/components/radix/aspect-ratio.md"
If .md doesn't exist (fallback):
curl -s "https://ui.shadcn.com/docs/components/radix/aspect-ratio"
Decision Tree
User provides URL
│
▼
Construct .md URL (append .md)
│
▼
curl -sI <markdown-url> | head -n 1
│
┌───┴───┐
│ │
200 OK 404/Other
│ │
▼ ▼
Fetch Fetch original
.md HTML URL
Quick Reference
| Check Command | Fetch Command |
|---|---|
curl -sI "<url>.md" | head -n 1 |
curl -s "<url>.md" |
curl -sI "<url>" | head -n 1 |
curl -s "<url>" |
Examples
Example 1: Markdown version available
# Check
curl -sI "https://ui.shadcn.com/docs/components/radix/aspect-ratio.md" | head -n 1
# Output: HTTP/2 200
# Fetch
curl -s "https://ui.shadcn.com/docs/components/radix/aspect-ratio.md"
Example 2: Markdown version not available
# Check
curl -sI "https://example.com/docs/guide.md" | head -n 1
# Output: HTTP/2 404
# Fallback - fetch original
curl -s "https://example.com/docs/guide"
More from 1naichii/ai-code-tools
convert-url-html-to-md
Convert HTML web pages to Markdown for documentation extraction. Use when fetching documentation from websites, extracting structured content, getting clean main content (clean=true), or getting full page with nav/sidebar to discover URLs (clean=false). Ideal for learning libraries and building context from web sources.
41daisyui
CSS component library for Tailwind CSS 4 providing pre-built UI components with semantic class names. Use when building web interfaces with HTML/Tailwind that need: (1) Rapid UI development with consistent styling, (2) Accessible component patterns (buttons, forms, modals, etc.), (3) Theme-aware color systems that work across light/dark modes, (4) Responsive layouts with Tailwind utilities. Works with daisyUI v5+ which requires Tailwind CSS v4+.
35laravel-livewire
Full-stack Laravel framework for building dynamic, reactive interfaces using PHP without writing JavaScript. Use when creating or modifying Livewire components, implementing data binding with wire:model, working with lifecycle hooks, building forms with validation, handling events and parent-child communication, implementing file uploads/pagination/lazy loading, writing tests, or optimizing performance. Supports Laravel Livewire v4+ development. Keywords: Livewire, wire:model, wire:click, livewire component, Alpine.js integration, wire:submit, real-time validation, computed properties, Laravel Livewire.
21inertia
Build modern monolith applications with Inertia.js - combining server-side frameworks (Laravel, Rails, etc.) with React/Vue/Svelte frontends without building APIs. Use when creating Inertia pages and layouts, working with Link component for navigation, building forms with Form component or useForm hook, handling validation and errors, managing shared data and props, implementing authentication and authorization, using manual visits with router, working with partial reloads, setting up persistent layouts, or configuring client-side setup.
12lucide-laravel
Lucide icon library integration for Laravel Blade templates. Use when working with Lucide icons in Laravel applications, Blade components with the x-lucide- prefix, icon styling with Tailwind CSS, dynamic icon rendering in Blade, or any Laravel view work requiring SVG icons. Keywords include lucide icons, blade icons, x-lucide, SVG icons Laravel, blade-lucide-icons, mallardduck/blade-lucide-icons.
12