mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 10:38:17 +08:00
docs: Add warning to version-specific docunmentation pages (#2248)
See details on issue #2214 Basically, we want to make users more aware they are looking at old version of the docs.
This commit is contained in:
@ -33,9 +33,22 @@ function convertVersionsToHtmlLinks(versionsList, currentVersion) {
|
||||
return out;
|
||||
}
|
||||
|
||||
function maybeAddWarning(versions, currentVersion) {
|
||||
const specialVersions = ['main', 'local'];
|
||||
const latestVersion = versions.filter(e => !specialVersions.includes(e))[0];
|
||||
const nonWarningVersions = [...specialVersions, latestVersion];
|
||||
const showWarning = !nonWarningVersions.includes(currentVersion);
|
||||
if (showWarning) {
|
||||
$('#version-warning')
|
||||
.find('.version').text(currentVersion).end()
|
||||
.removeClass('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
function buildVersionsMenu(data) {
|
||||
const versions = data.split('\n');
|
||||
const currentVersion = getCurrentDocVersion();
|
||||
const versionButtons = convertVersionsToHtmlLinks(data.split('\n'), currentVersion);
|
||||
const versionButtons = convertVersionsToHtmlLinks(versions, currentVersion);
|
||||
$('div.versions-placeholder').append(`
|
||||
<div id="versions-menu" tabindex="-1">
|
||||
<div class="btn">
|
||||
@ -54,6 +67,8 @@ function buildVersionsMenu(data) {
|
||||
// A timeout ensures that `click` can propagate to child <A/> elements.
|
||||
setTimeout(() => $(this).removeClass("active"), 200);
|
||||
});
|
||||
|
||||
maybeAddWarning(versions, currentVersion);
|
||||
}
|
||||
|
||||
// Start loading the versions list as soon as possible, don't wait for DOM
|
||||
|
||||
Reference in New Issue
Block a user