//custom post data
const likesWeight = 0.2
const viewsWeight = 0.8
$w.onReady(function () {
wixLocation.onChange((res) => {
freshState()
})
freshState()
});
function freshState(parameter) {
$w("#post1").getPost().then(async (res) => {
if (res) {
loadInfo(res)
}
})
}
async function loadInfo(postRes) {
let info = await postRes;
$w("#postTitle").text = await info.title;
$w("#timeToRead").text = await (info.timeToRead) ? info.timeToRead.toString() : "2";
$w("#views").text = await (info.viewCount) ? info.viewCount.toString() : "1";
$w("#likes").text = await (info.likeCount) ? info.likeCount.toString() : "0";
$w("#coverImage").src = await (info.coverImage)
}