random messages
This commit is contained in:
		@@ -1,9 +1,8 @@
 | 
			
		||||
---
 | 
			
		||||
import { metaData } from "../config";
 | 
			
		||||
import { Icon } from "astro-icon/components";
 | 
			
		||||
import { metaData, API_URL } from "../config";
 | 
			
		||||
import RandomMsg from "../components/RandomMsg";
 | 
			
		||||
 | 
			
		||||
const YEAR = new Date().getFullYear();
 | 
			
		||||
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
<small class="block lg:mt-24 mt-16 text-[#1C1C1C] dark:text-[#D4D4D4] footer-text">
 | 
			
		||||
@@ -11,6 +10,7 @@ const YEAR = new Date().getFullYear();
 | 
			
		||||
    {metaData.owner}
 | 
			
		||||
  </a>
 | 
			
		||||
</small>
 | 
			
		||||
<RandomMsg client:only="react" />
 | 
			
		||||
 | 
			
		||||
<style>
 | 
			
		||||
  @media screen and (max-width: 480px) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										28
									
								
								src/components/RandomMsg.jsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/components/RandomMsg.jsx
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
import { API_URL } from "../config";
 | 
			
		||||
import { default as $ } from "jquery";
 | 
			
		||||
 | 
			
		||||
var randomMsg;
 | 
			
		||||
 | 
			
		||||
const getRandomMsg = () => {
 | 
			
		||||
        $.ajax({
 | 
			
		||||
            url: API_URL+'/randmsg',
 | 
			
		||||
            method: "POST",
 | 
			
		||||
            contentType: "application/json; charset=utf-8"
 | 
			
		||||
        }).done(function (data) {
 | 
			
		||||
            if (! data.msg) {
 | 
			
		||||
                return;
 | 
			
		||||
            } else {
 | 
			
		||||
                randomMsg = data.msg.replace("<br>", "\n");
 | 
			
		||||
                $('.random-msg').html(`<small><i>${randomMsg}</i></small>`);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default function RandomMsg() {
 | 
			
		||||
    getRandomMsg();
 | 
			
		||||
        return (
 | 
			
		||||
            <div className="random-msg">
 | 
			
		||||
            </div>
 | 
			
		||||
        ); 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user