PHP to Javascript conversion [closed]

I have a small PHP script that I’ve been using for quite some time to generate link menus. Now, I have to create a menu of links on a server that does not have PHP capabilities. Javascript has been recommended, but I am not literate in that language. So, I tried an online PHP to Javascript converter, and it was only partially successful. Below is the PHP that I’ve been using. It checks the URL for the page name and applies one of two CSS property sets, depending on whether or not it is the currently loaded page.

<?php
$pageName = basename($_SERVER['REQUEST_URI']);
?>

<li class="<?php if ($pageName=="page1.html") {echo "linksactive"; } else  {echo "linksinactive";}?>"><a href="page1.html">Page 1</a></li>
<li class="<?php if ($pageName=="page2.html") {echo "linksactive"; } else  {echo "linksinactive";}?>"><a href="page2.html">Page 2</a></li>
<li class="<?php if ($pageName=="page3.html") {echo "linksactive"; } else  {echo "linksinactive";}?>"><a href="page3.html">Page 3</a></li>

Here is what the converter supplied =>

const pageName = window.location.pathname;

document.write(`
    <li class="${pageName === '/page1.html'? 'linksactive' : 'linksinactive'}"><a href="page1.html">Page 1</a></li>
    <li class="${pageName === '/page2.html'? 'linksactive' : 'linksinactive'}"><a href="page2.html">Page 2</a></li>
    <li class="${pageName === '/page3.html'? 'linksactive' : 'linksinactive'}"><a href="page3.html">Page 3</a></li>
`);

By partially successful, I mean it constructs the link list, and it applies the CSS associated with “linksinactive”; however, it does not apply the CSS associated with linksactive, implying that it does not recognize the current, active page.

I tried many other online converters, and either the result was the same, or the output was blank, or in one case, it applied some of the linksactive CSS, but obliterated the rest of the webpage.

Finally, the javascript is run as an external script, as follows.

<ul style="list-style-type:none; padding-left:0;">
                    
<script type="text/javascript" src="./.js/hymnlist.js"></script>
                    
</ul>

What did the converter miss in translation? Thanks.