-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2460 from airqo-platform/website-clean-air
updates UI website
- Loading branch information
Showing
9 changed files
with
109 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// src/utils/glossaryValidator.ts | ||
|
||
/** | ||
* Checks if the provided glossary HTML content is valid for display. | ||
* It removes any empty paragraphs (e.g., <p><br/></p>) and then checks | ||
* if the cleaned content contains any invalid snippets. | ||
* | ||
* @param html The HTML content to validate. | ||
* @returns {boolean} True if valid, false otherwise. | ||
*/ | ||
export function isValidGlossaryContent(html: string): boolean { | ||
if (!html) return false; | ||
|
||
// Remove empty paragraphs. This regex will remove <p><br/></p> or similar variants. | ||
const cleanedHTML = html.replace(/<p>\s*<br\s*\/?>\s*<\/p>/gi, '').trim(); | ||
|
||
const invalidSnippets = [ | ||
'<p><br/></p>', | ||
'No details available yet.', | ||
'Details coming soon.', | ||
]; | ||
|
||
// Check if the cleaned HTML contains any of the invalid snippets. | ||
for (const snippet of invalidSnippets) { | ||
if (cleanedHTML === snippet || cleanedHTML.includes(snippet)) { | ||
return false; | ||
} | ||
} | ||
|
||
return cleanedHTML.length > 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// src/utils/htmlValidator.ts | ||
|
||
/** | ||
* Checks if the provided HTML content is valid for display. | ||
* It will return false if the content is empty or if it contains any | ||
* unwanted placeholders like '<p><br/></p>', 'No details available yet.', or 'Details coming soon.'. | ||
* | ||
* @param html The HTML content to validate. | ||
* @returns {boolean} True if the content is valid, false otherwise. | ||
*/ | ||
export function isValidHTMLContent(html: string): boolean { | ||
const invalidSnippets = [ | ||
'<p><br/></p>', | ||
'No details available yet.', | ||
'Details coming soon.', | ||
]; | ||
|
||
// Trim the HTML to ensure we don't have just whitespace. | ||
const trimmedHTML = html.trim(); | ||
|
||
if (!trimmedHTML) return false; | ||
|
||
// Check if any invalid snippet exists in the HTML. | ||
for (const snippet of invalidSnippets) { | ||
if (trimmedHTML.includes(snippet)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} |