Skip to content

Commit

Permalink
attempting to dynamic tags, idfk if github pages will allow it
Browse files Browse the repository at this point in the history
  • Loading branch information
pixepchief committed Jun 23, 2024
1 parent 7d0300f commit 7b97040
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions deck/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<link rel="stylesheet" href="./style.css">
<link rel="icon" href="./favicon-32x32.png">
<meta content="100% Orange Juice Deck Builder" property="og:title">
<meta content="An online deck builder for the game 100% Orange Juice, fully in your web browser!" property="og:description">
<meta id = "ogDescriptionMeta" content="An online deck builder for the game 100% Orange Juice, fully in your web browser!" property="og:description">
<meta content="100% Orange Juice Deck Builder" property="og:site_name">
<meta content='https://pixepchief.github.io/100oj/images/siteLogo.png' property='og:image'>
<meta id = "ogImageMeta" content='https://pixepchief.github.io/100oj/images/siteLogo.png' property='og:image'>
<meta name="theme-color" content="#FFBE64">
<script src = "https://cdnjs.cloudflare.com/ajax/libs/tsparticles/1.18.11/tsparticles.min.js"> </script>
<script>
Expand Down
17 changes: 17 additions & 0 deletions deck/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ fetch('cards.json')
const encodedDeck = urlParams.get('deck');
deck = decodeDeck(encodedDeck);
updateDeckDisplay();
updateMetaDescription(deck);
}

function updateDeckDisplay() {
Expand Down Expand Up @@ -118,6 +119,22 @@ fetch('cards.json')
document.getElementById('page-number').innerText = `${currentPage}/${totalPages}`;
}

function updateMetaDescription(deck) {
const ogDescriptionMeta = document.getElementById('ogDescriptionMeta');
const ogImageMeta = document.getElementById('ogImageMeta');
if (ogDescriptionMeta && ogImageMeta) {
const firstCard = deck.find(card => card !== null);
if (firstCard) {
const deckDescription = deck.filter(card => card !== null).map(card => card.name).join(', ');
ogDescriptionMeta.setAttribute('content', `A shared deck that contains the cards: ${deckDescription}`);
ogImageMeta.setAttribute('content', `https://orangejuice.wiki/${firstCard.picture}`);
} else {
ogDescriptionMeta.setAttribute('content', `An online deck builder for the game 100% Orange Juice, fully in your web browser!`);
ogImageMeta.setAttribute('content', `https://orangejuice.wiki/w/images/Images/100OrangeJuice_images/2/2d/Back_0.png`);
}
}
}

document.getElementById('prev-page').addEventListener('click', () => {
if (currentPage > 1) {
currentPage--;
Expand Down

0 comments on commit 7b97040

Please sign in to comment.