@@ -1708,6 +1708,36 @@ async function get_docs(
17081708 );
17091709}
17101710
1711+ function transform_cloudflare(
1712+ docs,
1713+ { project, type, keyby, version = "latest" }
1714+ ) {
1715+ const keys = [
1716+ {
1717+ key: `${project}@${version}:${type}:content`,
1718+ value: JSON.stringify(docs.full),
1719+ },
1720+ ];
1721+
1722+ for (let i = 0; i < docs.full.length; i++) {
1723+ // const { content, ...rest } = docs[i];
1724+
1725+ const item_key = docs.full[i][keyby];
1726+
1727+ keys.push({
1728+ key: `${project}@${version}:${type}:${item_key}`,
1729+ value: JSON.stringify(docs.full[i]),
1730+ });
1731+ }
1732+
1733+ keys.push({
1734+ key: `${project}@${version}:${type}:list`,
1735+ value: JSON.stringify(docs.list),
1736+ });
1737+
1738+ return keys;
1739+ }
1740+
17111741var escapeStringRegexp$1 = string => {
17121742 if (typeof string !== 'string') {
17131743 throw new TypeError('Expected a string');
@@ -26103,6 +26133,17 @@ async function run() {
2610326133
2610426134 console.log(JSON.stringify(transformed_docs, null, 2));
2610526135
26136+ const ready_for_cf = transformed_docs
26137+ .map((d) =>
26138+ d.map(({ content, project, type }) =>
26139+ //@ts-ignore
26140+ transform_cloudflare(content, { project, type, keyby: "slug" })
26141+ )
26142+ )
26143+ .flat();
26144+
26145+ console.log(JSON.stringify(ready_for_cf, null, 2));
26146+
2610626147 // if (docs.length) {
2610726148 // docs.forEach(([project, docs]) => {
2610826149 // for (const type in docs) {
0 commit comments