mirror of
https://gitee.com/butubb8/blowfish.git
synced 2025-12-05 14:17:50 +08:00
feat: add huggingface shortcode (#2376)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user