Custom blogger posts permalink using workers

hello, I want to customize the permalinks of blogger posts using Cloudflare workers. Previously I had customized the blogger static page /p/ but if the blogger posts had different years and months, it confused me. the code is like this for the custom static page.

addEventListener(“fetch”, event => {
const url = new URL(event.request.url.replace(‘/page/’, ‘/’))
let BASE = ‘
const OLD_URL = BASE + ‘/p’ + url.pathname +‘.html’;
const NEW_URL = BASE + ‘/page’+ url.pathname;

async function handleRequest(req) {
const res = await fetch(req)
return rewriter.transform(res)
class AttributeRewriter {
constructor(attributeName) {
this.attributeName = attributeName
element(element) {
const attribute = element.getAttribute(this.attributeName)
if (attribute) {
attribute.replace(OLD_URL, NEW_URL)
const rewriter = new HTMLRewriter()
.on(“link”, new AttributeRewriter(“href”))
.on(“meta”, new AttributeRewriter(“content”))
.catch(err => new Response(err.toString(),{status:500})))

it’s not my own coding but I got it from someone else. and it worked I applied it on my blogger website only static pages. for example like this for blogger static page Diskusi - Marwanto606

if for the post page what can also be done like that?