Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion scripts/preghpages.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,34 @@ shell.cp('-r', [
'*.md'
], 'gh-pages');

// Track which HTML files had at least one link replaced, so the CodeSandbox
// style below is only injected into the examples we actually modified.
const modifiedFiles = new Set();

function htmlReplace (before, after) {
replaceInFileSync({
const results = replaceInFileSync({
from: before,
to: after,
files: 'gh-pages/**/*.html'
});
results.filter(result => result.hasChanged).forEach(result => modifiedFiles.add(result.file));
}

htmlReplace('../../../dist/aframe-master.module.min.js', `https://aframe.io/releases/${aframeVersion}/aframe.module.min.js`);
htmlReplace('../../../dist/aframe-master.js', `https://aframe.io/releases/${aframeVersion}/aframe.min.js`);
htmlReplace(/\.\.\/\.\.\/\.\.\/super-three-package/g, `https://cdn.jsdelivr.net/npm/super-three@${threeVersion}`);

// Move the CodeSandbox "Open Sandbox" button to the top so it does not overlap
// the VR/AR enter buttons, but only in the examples where a link was replaced.
if (modifiedFiles.size > 0) {
replaceInFileSync({
from: '</head>',
to: ` <style>
iframe[id^="sb__open-sandbox"] {
inset: 16px auto auto 16px;
}
</style>
</head>`,
files: Array.from(modifiedFiles)
});
}
Loading