Since a “Back” button feature isn’t conveniently ready yet, I managed to code one using Corvid for my Blog Post page. I needed a back button since I have customized my Blog into different pages per categories using a menu & blog custom feed.
1st: I made sure I created a button with ID #btnBack.
2nd: On Site Code I wrote the following code:
import {session} from 'wix-storage';
import wixSite from 'wix-site';
import wixLocation from 'wix-location';
$w.onReady(function () {
let currentPage = wixSite.currentPage.url;
let postPageUrl = '/post'; //wixSite url page with back button
//set session only when not in POST PAGE
if(wixSite.currentPage.url !== postPageUrl){
session.setItem("pageTrail", currentPage);
}
});
3rd: I intend to only get the session pagetrail when I am in my target page where I need my back button. Under the Post Page code, I applied the following code:
import {session} from 'wix-storage';
import wixLocation from 'wix-location';
$w.onReady(function () {
let backTarget = session.getItem("pageTrail");
$w("#btnBack").onClick( () => {
wixLocation.to(backTarget);
})
});