Khi deploy Cloudflare Pages, mật khẩu lấy từ biến môi trường ADMIN_PASSWORD.
Đang ở chế độ Admin — có thể thêm, sửa, xoá bài viết.
🎲
💡 Từ khoá được tô vàng
⚡ Lưu nhanh
Thêm bài viết mới
🗂 Danh mục & Cài đặt
Thêm danh mục mới
⚙️ Supabase & Backup
🛠 Cài đặt Supabase
1
Tạo project Supabase
Vào supabase.com → New project → điền tên và mật khẩu database → chờ khoảng 1 phút.
2
Chạy SQL tạo bảng
Vào SQL Editor trong Supabase → paste đoạn SQL này → bấm Run:
create table if not exists items (
id text primary key,
cat text not null default 'other',
title text not null,
content text not null,
tags text[] default '{}',
source text default '',
date bigint not null,
fav boolean default false
);
create table if not exists cats (
id text primary key,
label text not null,
emoji text default '✨',
color text default '#7A5200',
built_in boolean default false,
sort_order int default 99
);
-- Cho phép đọc công khai (public read)
alter table items enable row level security;
alter table cats enable row level security;
create policy "public read items"
on items for select using (true);
create policy "public read cats"
on cats for select using (true);
-- Không tạo policy ghi public.
-- Cloudflare Pages Function sẽ ghi bằng SUPABASE_SERVICE_ROLE_KEY trong Environment variables.
-- Insert danh mục mặc định
insert into cats (id,label,emoji,color,built_in,sort_order) values
('caption','Caption','😂','#C4501A',true,1),
('story','Truyện','📖','#1A5C4A',true,2),
('tip','Tip & Trick','💡','#4A3A8C',true,3),
('other','Khác','✨','#7A5200',true,4)
on conflict (id) do nothing;
3
Lấy URL và API Key
Vào Project Settings → API:
• Project URL — dán vào ô URL bên dưới
• anon public key — dán vào ô Anon Key (dùng cho đọc)
• service_role key — đặt trong Cloudflare Pages Environment variables, không dán vào trình duyệt
4
Điền thông tin kết nối
Supabase Project URL
Anon Key (public — dùng để đọc)
5
Kết nối & đồng bộ dữ liệu
Bấm Kết nối để kiểm tra. Nếu thành công, bấm "Đẩy dữ liệu lên" để upload toàn bộ bài viết từ máy bạn lên Supabase.