Skip to content

Commit

Permalink
feat: Updated deploy script to map legacy docs links
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobinstein committed Dec 18, 2024
1 parent 3045f1b commit 37a1f0f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/scripts/arweave-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,46 @@ async function main() {

manifest.paths = updatedPaths;

// After you've constructed updatedPaths and before uploading the manifest:
const legacyPaths = require('./legacy-paths.json');

Object.keys(legacyPaths).forEach((legacyKey) => {
const newVersionPath = legacyPaths[legacyKey];
const dataItem = updatedPaths[newVersionPath];

if (!dataItem) {
console.warn(`No matching data item found for ${newVersionPath}, legacy key ${legacyKey} not added.`);
return;
}

// Add the original legacy key
if (!updatedPaths.hasOwnProperty(legacyKey)) {
updatedPaths[legacyKey] = dataItem;
console.log(`Added legacy manifest key: ${legacyKey} -> ${newVersionPath}`);
}

// Handle shortened paths:
// If ends with "index.html", remove "index.html"
if (legacyKey.endsWith("index.html")) {
const shortenedKey = legacyKey.replace(/index\.html$/, "");
if (!updatedPaths.hasOwnProperty(shortenedKey)) {
updatedPaths[shortenedKey] = dataItem;
console.log(`Added legacy shortened manifest key: ${shortenedKey} -> ${newVersionPath}`);
}
}
// Else if ends with ".html" but not "index.html", remove ".html"
else if (legacyKey.endsWith(".html")) {
const shortenedKey = legacyKey.replace(/\.html$/, "");
if (!updatedPaths.hasOwnProperty(shortenedKey)) {
updatedPaths[shortenedKey] = dataItem;
console.log(`Added legacy shortened manifest key: ${shortenedKey} -> ${newVersionPath}`);
}
}
});

// Now updatedPaths includes both the new shortened URLs and the legacy paths
manifest.paths = updatedPaths;

async function uploadManifest(manifest) {
try {
const manifestString = JSON.stringify(manifest);
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/scripts/legacy-paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"troubleshooting-observer/index.html": "build/gateways/observer",
"arns/index.html": "learn/arns",
"arweave/index.html": "learn/network-composition",
"community-resources.html": "community-resources",
"concepts/normalized-addresses/index.html": "learn/concepts/normalized-addresses",
"concepts/sandboxing.html": "learn/concepts/sandboxing"
}

0 comments on commit 37a1f0f

Please sign in to comment.