fix: ansible card values are build-time only (Galaxy blocks CORS)

This commit is contained in:
Kevin Horst committed 2026-05-08 19:26:55 +02:00
1 parent 88863335fd
commit a9869a55a6
3 files changed
+6 -36

No files matched your search

+1 -24
View File
@@ -12,14 +12,6 @@
}
const platforms = {
"ansible-role": {
"results.0.download_count": "downloads",
"results.0.summary_fields.versions.0.name": "version",
},
"ansible-collection": {
download_count: "downloads",
"highest_version.version": "version",
},
github: {
full_name: "full_name",
description: "description",
@@ -57,27 +49,12 @@
},
};
const formatThousands = (value) =>
value == null ? value : Number(value).toLocaleString("en-US");
const processors = {
huggingface: {
description: (value) => value?.replace(/Dataset Card for .+?\s+Dataset Summary\s+/, "").trim() || value,
},
"ansible-role": {
"results.0.download_count": formatThousands,
},
"ansible-collection": {
download_count: formatThousands,
},
};
const getNested = (obj, path) =>
path.split(".").reduce((acc, key) => {
if (acc == null) return undefined;
return Array.isArray(acc) ? acc[Number(key)] : acc[key];
}, obj);
const platform = Object.keys(platforms).find((p) => repoId.startsWith(p)) || "github";
const mapping = platforms[platform];
@@ -100,7 +77,7 @@
Object.entries(mapping).forEach(([dataField, elementSuffix]) => {
const element = document.getElementById(`${repoId}-${elementSuffix}`);
if (element) {
let value = getNested(data, dataField);
let value = data[dataField];
if (processors[platform]?.[dataField]) {
value = processors[platform][dataField](value);
}