Skip to content

Commit

Permalink
Merge pull request #7 from steffenbew/main
Browse files Browse the repository at this point in the history
fix(main.js): allow tracking to boards (not just pulses) with default values
  • Loading branch information
timohubois authored Jul 16, 2024
2 parents 8da5b16 + 40c9d47 commit 3a3ab08
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,15 @@ async function getDataFromMonday() {
const path = window.location.pathname;
const urlBase = new URL(window.location.href).origin;

// Initialize default values
// Initialize variables
let projectName = '';
let pulseName = 'Miscellaneous > REPLACE_THIS_WITH_A_DESCRIPTION';
let pulseId = 'miscellaneous';
let pulseName = '';
let pulseId = '';
let boardId = '';
let permalink = '';

// Extract boardId and pulseId from path
const pathRegex = /\/boards\/(\d+)\/?.*\/pulses\/(\d+)/;
const pathRegex = /\/boards\/(\d+)(?:\/?.*\/pulses\/(\d+))?/;
const pathMatch = path.match(pathRegex);

if (pathMatch) {
Expand All @@ -278,13 +278,14 @@ async function getDataFromMonday() {

// Fetch pulseName
const pulseNameElement = document.querySelector('.pulse_title h2');
pulseName = pulseNameElement?.textContent || '';
pulseName = pulseNameElement?.textContent || 'Miscellaneous > REPLACE_THIS_WITH_A_DESCRIPTION'; // Harvest requires a default value

// Construct permalink
if (boardId) {
if (pulseId) {
permalink = `${urlBase}/boards/${boardId}/pulses/${pulseId}`;
} else {
pulseId = 'miscellaneous'; // Harvest requires a default value
permalink = `${urlBase}/boards/${boardId}`;
}
}
Expand Down

0 comments on commit 3a3ab08

Please sign in to comment.