JSON 后台编辑器
用途:维护 posts.json 与 site.json,导出后用于 build。
帖子管理
站点配置
\n",
"ads": {
"header": "",
"infeed": "",
"post": ""
},
"postsPerPage": 12
};
const postsInput = document.getElementById("postsInput");
const siteInput = document.getElementById("siteInput");
postsInput.value = JSON.stringify(seedPosts, null, 2);
siteInput.value = JSON.stringify(seedSite, null, 2);
document.getElementById("formatPosts").addEventListener("click", () => {
postsInput.value = JSON.stringify(JSON.parse(postsInput.value), null, 2);
});
document.getElementById("formatSite").addEventListener("click", () => {
siteInput.value = JSON.stringify(JSON.parse(siteInput.value), null, 2);
});
document.getElementById("downloadPosts").addEventListener("click", () => download("posts.json", postsInput.value));
document.getElementById("downloadSite").addEventListener("click", () => download("site.json", siteInput.value));
function download(name, content) {
const blob = new Blob([content], { type: "application/json;charset=utf-8" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = name;
a.click();
URL.revokeObjectURL(url);
}