Update OpenGraph metadata in subpages

Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
Sebastian Martinez
2022-02-09 16:07:10 +01:00
committed by Alexis Sellier
parent 7b4c635c64
commit 1e827eb458
5 changed files with 30 additions and 4 deletions
+2 -2
View File
@@ -64,10 +64,10 @@ export async function toClipboard(text: string): Promise<void> {
return navigator.clipboard.writeText(text);
}
export function setOpenGraphMetaTag(data: {prop: string, content: string, attr?: string }[]): void {
export function setOpenGraphMetaTag(data: { prop: string; content: string; attr?: string }[]): void {
const elements = Array.from<HTMLElement>(document.querySelectorAll(`meta`));
elements.forEach((element: any) => {
let foundElement = data.find(data => {
const foundElement = data.find(data => {
return data.prop === element.getAttribute(data.attr || 'property');
});
if (foundElement) element.content = foundElement.content;