Merge pull request #2378 from ZhenShuo2021/feat/huggingface-card

 Feat: add huggingface shortcode
This commit is contained in:
Nuno C.
2025-08-03 01:44:17 +01:00
committed by GitHub
6 changed files with 247 additions and 19 deletions
+18 -1
View File
@@ -36,6 +36,17 @@
stars_count: "stars_count",
forks_count: "forks_count",
},
huggingface: {
description: "description",
likes: "likes",
downloads: "downloads",
},
};
const processors = {
huggingface: {
description: (value) => value?.replace(/Dataset Card for .+?\s+Dataset Summary\s+/, "").trim() || value,
},
};
const platform = Object.keys(platforms).find((p) => repoId.startsWith(p)) || "github";
@@ -49,7 +60,13 @@
Object.entries(mapping).forEach(([dataField, elementSuffix]) => {
const element = document.getElementById(`${repoId}-${elementSuffix}`);
if (element) element.innerHTML = data[dataField];
if (element) {
let value = data[dataField];
if (processors[platform]?.[dataField]) {
value = processors[platform][dataField](value);
}
element.innerHTML = value;
}
});
} catch (error) {
console.error(error);