Skip to content

Commit

Permalink
chore(docs): add docs footer customization (#4169)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Nov 11, 2022
1 parent e4ea7d0 commit 44f2228
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -12,7 +12,7 @@
"build:clients:generic": "lerna run --scope '@aws-sdk/aws-echo-service' --include-dependencies build",
"build:clients:since:release": "yarn build:packages && lerna run build $(lerna changed | grep -e '@aws-sdk/[client|lib]-*' | sed 's/^/ --scope /' | tr '\n' ' ')",
"build:crypto-dependencies": "lerna run --scope '@aws-sdk/{types,util-utf8-browser,util-locate-window,hash-node}' --include-dependencies build",
"build:docs": "typedoc",
"build:docs": "typedoc && node scripts/docs-custom-js",
"build:e2e": "yarn build:crypto-dependencies && lerna run --scope '@aws-sdk/{client-cloudformation,karma-credential-loader,client-s3-control,client-sts}' --include-dependencies build",
"build:packages": "lerna run build --ignore '@aws-sdk/client-*' --ignore '@aws-sdk/aws-*' --ignore '@aws-sdk/lib-*' --include-dependencies",
"build:protocols": "yarn build:crypto-dependencies && lerna run --scope '@aws-sdk/aws-protocoltests-*' --include-dependencies build",
Expand Down
27 changes: 27 additions & 0 deletions scripts/docs-custom-js/aws-footer.js
@@ -0,0 +1,27 @@
!(function () {
var guideName = document.createElement("meta");
(guideName.name = "guide-name"), (guideName.content = "API Reference");

var serviceName = document.createElement("meta");
(serviceName.name = "service-name"), (serviceName.content = "AWS SDK for JavaScript v3");

document.head.appendChild(guideName);
document.head.appendChild(serviceName);

var zone = document.createElement("div");
zone.className += "container";
zone.id = "awsdocs-legal-zone-copyright";
zone.style.padding = "2rem";

var footer = document.getElementsByTagName("footer");
if (footer && footer.length >= 1) {
footer[footer.length - 1].appendChild(zone);
} else {
document.body.appendChild(zone);
}

var boot = document.createElement("script");
boot.src = "/assets/js/awsdocs-boot.js";
boot.type = "text/javascript";
document.head.appendChild(boot);
})();
1 change: 1 addition & 0 deletions scripts/docs-custom-js/index.js
@@ -0,0 +1 @@
require("./prepend-script");
20 changes: 20 additions & 0 deletions scripts/docs-custom-js/prepend-script.js
@@ -0,0 +1,20 @@
const fs = require("fs");
const path = require("path");

const root = path.join(__dirname, "..", "..");
const awsFooter = path.join(root, "scripts", "docs-custom-js", "aws-footer.js");
const docsMainScript = path.join(root, "docs", "assets", "js", "main.js");

if (!fs.existsSync(docsMainScript)) {
throw new Error(`docs main script not present at ${docsMainScript}`);
}

const fileContents = fs.readFileSync(docsMainScript, "utf-8");
const awsFooterContents = fs.readFileSync(awsFooter, "utf-8");

if (fileContents.indexOf(awsFooterContents) === -1) {
fs.writeFileSync(docsMainScript, awsFooterContents + "\n" + fileContents, "utf-8");
console.log("Modified docs script with AWS footer script.");
} else {
console.log("Docs main script already modified, exiting.");
}

0 comments on commit 44f2228

Please sign in to comment.