Skip to content

Commit

Permalink
Change page description based on question title in vote and results page
Browse files Browse the repository at this point in the history
  • Loading branch information
dginovker committed Feb 25, 2024
1 parent 6f22e6e commit 24232b8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
get(pollRef).then((snapshot) => {
if (snapshot.exists()) {
const pollData = snapshot.val();

document.querySelector('meta[name="description"]').setAttribute("content", pollData.question + " - Vote now on Strawpoll.lol");

// Create the HTML for the voting options
let html = `<h1>${pollData.question}</h1>`;
pollData.options.forEach((option, index) => {
Expand Down Expand Up @@ -86,6 +89,8 @@
onValue(pollRef, (snapshot) => {
if (snapshot.exists()) {
const data = snapshot.val();
document.querySelector('meta[name="description"]').setAttribute("content", data.question + " - See results on Strawpoll.lol");

// Calculate total votes
const totalVotes = Object.values(data.votes).reduce((total, num) => total + num, 0);

Expand Down

0 comments on commit 24232b8

Please sign in to comment.