mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 15:31:52 +00:00
feat: add huggingface shortcode (#2376)
This commit is contained in:
+18
-1
@@ -36,6 +36,17 @@
|
|||||||
stars_count: "stars_count",
|
stars_count: "stars_count",
|
||||||
forks_count: "forks_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";
|
const platform = Object.keys(platforms).find((p) => repoId.startsWith(p)) || "github";
|
||||||
@@ -49,7 +60,13 @@
|
|||||||
|
|
||||||
Object.entries(mapping).forEach(([dataField, elementSuffix]) => {
|
Object.entries(mapping).forEach(([dataField, elementSuffix]) => {
|
||||||
const element = document.getElementById(`${repoId}-${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) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user