'Can I create a dynamic preview using firebase hosting?

Can I create a dynamic preview using firebase hosting?

The data tag is in use, but it is not applied.

This is the HTML code.

<html>
<head>
    <meta property="og:title" content="채팅방 공유" />
    <meta property="og:description" content="이미지를 클릭하여 채팅방에 참여하세요" />
    <meta property="og:type" content="website" />
    <meta property="og:url" content="" />
    <meta property="og:image" content=""/>

    <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta HTTP-EQUIV="Expires" CONTENT="-1">

    <script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-storage.js"></script>
    <script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-firestore.js"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.slim.js" integrity="sha256-HwWONEZrpuoh951cQD1ov2HUK5zA5DwJ1DNUXaM6FsY=" crossorigin="anonymous"></script>
    <script type="text/javascript" src="share.js"></script>
    <script async>
        var _url = new URL(location.href);
        var _urlParams = _url.searchParams;
        var _code = _urlParams.get('code');

        if(_code == null || _code == '') {
            location.href='https://localhost:5000';
        } else {
            async function run() {
                var title = await getRoomTitle(_code);
                console.log('async title = '+ title);
               var _result = title + ' 에 초대합니다';
               $("meta[property='og\\:title']").attr("content", _result);
            }
        }
        run();
    </script>
<body>
<a>잠시만 기다려주세요.</a>
</body>
</head>
</html>

This is the javascript code.

async function getRoomTitle(roomNo) {
    var value = await db.collection('TALK').doc(roomNo).get();
    if(value.data() != null) {
         var _data = value.data();
         var title = _data['title'];
         console.log('_data= ' + title);
         return title;
    } else {
        console.log('collection select error');
        return '';
    }
}

I am using firebase hosting and would like to change og:title.

Is there a way?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source