amp-shortlink

📗 PANDUAN AMP + SHORTLINK WORKER (Cloudflare)

🚀 Anti-blokir Komdigi — mobile dapat AMP, desktop dapat Full! 🔗 Worker: shortlink.dewamalaikat1981.workers.dev


🧠 KONSEP DASAR

Website kamu punya 2 versi:
📱 AMP (cepat, ringan) → amp.html  → untuk HP
💻 FULL (lengkap)      → index.html → untuk desktop

CARA KERJA:
User buka link short → Worker cek device:
├── 📱 HP     → redirect ke amp.html (versi AMP!)
└── 💻 Desktop → redirect ke index.html (versi FULL!)

= Komdigi susah blokir (halaman beda per device!)
= User HP dapat loading CEPAT (AMP!)

📂 STRUKTUR WEBSITE (contoh amanbos99.com)

/var/www/domains/amanbos99.com/  (atau folder Pages)
├── index.html   ← versi FULL (desktop)
├── amp.html     ← versi AMP (mobile)
├── css/
└── js/

📱 CARA BIKIN HALAMAN AMP

1. Struktur dasar amp.html:

<!DOCTYPE html>
<html amp lang="id">
<head>
  <meta charset="utf-8">
  <script async src="https://cdn.ampproject.org/v0.js"></script>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Judul Website</title>
  <style amp-custom>
    /* CSS kamu di sini — TIDAK boleh pakai <style> biasa */
    body { font-family: Arial; margin: 0; padding: 20px; }
    h1 { color: #333; }
  </style>
</head>
<body>
  <h1>Selamat Datang!</h1>
  <p>Ini versi AMP — super cepat di HP!</p>
</body>
</html>

2. Aturan AMP penting:

✅ WAJIB: <html amp> + <script amp v0.js> + <meta viewport>
✅ CSS di <style amp-custom> (gak boleh <style> biasa)
❌ Gak boleh: JavaScript custom (pakai komponen AMP!)
❌ Gak boleh: <img> biasa — WAJIB <amp-img>
   <amp-img src="gambar.jpg" width="300" height="200" layout="responsive"></amp-img>

3. Validasi AMP:

1. Buka https://validator.ampproject.org
2. Paste kode amp.html kamu
3. Kalau hijau ✅ = AMP valid!

1. Isi Worker (Cloudflare Dashboard):

1. dash.cloudflare.com → Workers & Pages
2. Buka worker: shortlink (atau buat baru)
3. Edit code:
// ===== SHORTLINK WORKER — AMP vs FULL =====
export default {
  async fetch(request) {
    const url = new URL(request.url);
    const path = url.pathname.replace(/^\//, '');

    // === DAFTAR LINK (edit di sini! 30 detik!) ===
    const LINKS = {
      // path         : { amp: "URL AMP", full: "URL FULL" }
      "amanbos":  { amp: "https://amanbos99.com/amp.html", full: "https://amanbos99.com" },
      "sayasuka": { amp: "https://sayasuka99.com/amp.html", full: "https://sayasuka99.com" },
      "enak":     { amp: "https://enakkakak99.com/amp.html", full: "https://enakkakak99.com" },
      "vpn":      { amp: "https://vpn.sayasuka99.com/amp.html", full: "https://vpn.sayasuka99.com" },
      "blog":     { amp: "https://chokdi-blog.pages.dev/amp.html", full: "https://chokdi-blog.pages.dev" },
      "fg":       { amp: "https://fastgaji-web.pages.dev/amp.html", full: "https://fastgaji-web.pages.dev" },
    };

    if (LINKS[path]) {
      // Deteksi device: HP atau Desktop?
      const ua = request.headers.get('User-Agent') || '';
      const isMobile = /Android|iPhone|iPad|Mobile/i.test(ua);

      const target = isMobile ? LINKS[path].amp : LINKS[path].full;
      return Response.redirect(target, 302);
    }

    // Root worker → halaman daftar
    const list = Object.entries(LINKS).map(([k, v]) =>
      `<a href="/${k}">/${k}${v.full}</a><br>`).join('');
    return new Response(
      `<h2>🔗 Shortlink Shield</h2><p>${list}</p>
       <p>💡 HP → AMP | Desktop → FULL</p>`,
      { headers: { "Content-Type": "text/html" } }
    );
  }
};

2. Deploy Worker:

Cloudflare Dashboard → Worker → Save & Deploy
→ LANGSUNG JALAN! (30 detik!)
📱 User HP buka:  shortlink.dewamalaikat1981.workers.dev/amanbos
   → LANGSUNG ke amanbos99.com/amp.html (AMP!)

💻 User desktop buka: shortlink.dewamalaikat1981.workers.dev/amanbos
   → ke amanbos99.com (FULL!)

= 1 LINK pendek → otomatis milih versi!

1. Buka worker shortlink di dashboard CF
2. Edit baris LINKS → ganti URL
3. Save & Deploy
4. SELESAI dalam 30 DETIK!

Contoh: amanbos diblokir → ganti ke domain baru:
  "amanbos": { amp: "https://amanbos99.net/amp.html", full: "https://amanbos99.net" },

🧠 FAQ

“amp.html harus upload?”

IYA — versi AMP harus dibuat & di-upload dulu!
(ZIP website → File Manager → upload amp.html!)

“Kalau gak punya amp.html?”

Worker tetap jalan — HP juga dapat versi full:
  "amanbos": { amp: "https://amanbos99.com", full: "https://amanbos99.com" },
(pakai URL sama untuk amp & full!)
BISA — cuma isi amp & full dengan URL yang sama:
  "download": { amp: "https://drive.google.com/...", full: "https://drive.google.com/..." },
BISA — path bebas:
  shortlink.dewamalaikat1981.workers.dev/vpn
  shortlink.dewamalaikat1981.workers.dev/saya
  → tinggal tambah di LINKS!

📌 Dibuat oleh Chokdi 🐷 — semalam kita bikin, sekarang dipandu! 🚀 Anti-blokir dengan AMP + Shortlink Worker!