Skip to content

Commit

Permalink
Deploying to gh-pages - 09:19:37
Browse files Browse the repository at this point in the history
  • Loading branch information
sdelamo committed Jun 10, 2024
1 parent 2a613ab commit 2f5a21c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion snapshot/js/multi-language-sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ function postProcessCodeBlocks() {
return string.charAt(0).toUpperCase() + string.slice(1);
}

function ensureAtLeastOneCodeBlockIsVisible(collectionOfSampleElements) {
if (collectionOfSampleElements.length > 0 && collectionOfSampleElements.every(a => a.classList.contains("hidden"))) {
const firstElement = collectionOfSampleElements[0];
console.info("No code snippet in default preferred language, showing first", firstElement)
firstElement.classList.remove("hidden")
}
}

function processSampleEl(sampleEl, prefLangId, prefBuildId, prefConfigId) {
var codeEl = sampleEl.querySelector("code[data-lang]");
if (codeEl != null) {
Expand Down Expand Up @@ -181,7 +189,7 @@ function postProcessCodeBlocks() {
processSampleEl(currentSampleElement, languageId, buildId, configId);
i++;
}

ensureAtLeastOneCodeBlockIsVisible(currentCollection);
multiLanguageSets.push(currentCollection);
}

Expand Down

0 comments on commit 2f5a21c

Please sign in to comment.