Skip to content

Commit

Permalink
Add theme color to meta
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcarol committed Dec 21, 2024
1 parent ea3ae94 commit 8c74733
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tools/importer/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,25 @@ function getBreadcrumbs(html, pathname) {
return breadcrumbs;
}

function getThemeColor(html) {
const themeColorRegex = /--theme-color: (#[0-9a-fA-F]{6});/g;
const themeColorMatch = themeColorRegex.exec(html);

return themeColorMatch[1];
}

const preprocessMetadata = {};

function createMetadata(main, document, pathname, html) {
const meta = preprocessMetadata;

const urlInfo = urls.find(({ URL: url }) => (new URL(url).pathname) === pathname);
meta.Theme = urlInfo.Theme;
const themeColor = getThemeColor(html);
report.themeColor = themeColor;
if (themeColor !== '') {
meta.ThemeColor = themeColor;
}
theme = meta.Theme;

meta.Title = document.querySelector('meta[property="og:title"]').content;
Expand Down Expand Up @@ -853,9 +865,7 @@ function findIcon(iconNode) {
}

function inlineIcons(main, html) {
const themeColorRegex = /--theme-color: (#[0-9a-fA-F]{6});/g;
const themeColorMatch = themeColorRegex.exec(html);
const themeColor = themeColorMatch[1];
const themeColor = getThemeColor(html);

const foundIcons = [];
const notFoundIcons = [];
Expand Down

0 comments on commit 8c74733

Please sign in to comment.