diff --git a/nextVersion.js b/nextVersion.js
index 3cf1b88c12..17f0eb2c0e 100644
--- a/nextVersion.js
+++ b/nextVersion.js
@@ -15,11 +15,13 @@
* along with Moodle. If not, see .
*/
+const latestVersion = '4.5';
const nextVersion = '5.0';
const nextLTSVersion = '5.3';
const nextVersionRoot = `/docs/${nextVersion}`;
module.exports = {
+ latestVersion,
nextVersion,
nextLTSVersion,
nextVersionRoot,
diff --git a/src/theme/MoodlePageBanner/index.js b/src/theme/MoodlePageBanner/index.js
index 766abdeb03..ffc0d19549 100644
--- a/src/theme/MoodlePageBanner/index.js
+++ b/src/theme/MoodlePageBanner/index.js
@@ -28,6 +28,7 @@ export default function MoodlePageBanner({ frontMatter, metadata = {} }) {
/>
>
);
diff --git a/src/theme/UnsupportedVersionBanner/index.js b/src/theme/UnsupportedVersionBanner/index.js
index 4a46ec6d8c..84b7b03d5a 100644
--- a/src/theme/UnsupportedVersionBanner/index.js
+++ b/src/theme/UnsupportedVersionBanner/index.js
@@ -21,6 +21,12 @@ import Translate from '@docusaurus/Translate';
import AutoFixHighIcon from '@mui/icons-material/AutoFixHigh';
import Admonition from '@theme/Admonition';
import { getReleaseStatus, getVersion } from '@site/src/utils/SupportedReleases';
+import {
+ useActivePlugin,
+ useDocVersionSuggestions,
+} from '@docusaurus/plugin-content-docs/client';
+
+const getVersionMainDoc = (version) => version.docs.find((doc) => doc.id === version.mainDocId);
function UnsupportedTitle() {
return (
@@ -93,6 +99,34 @@ function GeneralSupportExpiredWarning({ versionData }) {
);
}
+function NewerVersionAvailableWarning({ versionData }) {
+ const { pluginId } = useActivePlugin({ failfast: true });
+ const { latestDocSuggestion, latestVersionSuggestion } = useDocVersionSuggestions(pluginId);
+ const latestVersionSuggestedDoc = latestDocSuggestion ?? getVersionMainDoc(latestVersionSuggestion);
+
+ return (
+
+ }
+ title="Newer Version Available"
+ >
+
+ This documentation is for Moodle
+ {' '}
+ {versionData.name}
+ .
+
+
+ You may also want to read the documentation for the
+ {' '}
+ upcoming version of Moodle
+ .
+
+ );
+}
+
function FutureReleaseWarning({ versionData }) {
return (
);
}
+ if (sidebar === 'docs' && moodleVersion.version !== 'current' && metadata.slug !== '/') {
+ // This is a versioned doc page but it's not the 'current' version (main branch).
+ // Show a warning banner that that there are docs for the 'main' branch.
+ return (
+
+ );
+ }
+
if (releaseStatus === 'current') {
- // Still in general support.
+ // This documentation is for docs still in general support.
return null;
}
if (releaseStatus === 'future' || releaseStatus === 'future-stable') {
- // Not yet supported.
+ // This documentatino relates to a versino of Moodle which has yet to be released.
+ // This is probably a version about to be released.
// TODO Add a warning banner.
return (
@@ -197,8 +253,21 @@ function VersionedSupportWarning({ versionData, moodleVersion }) {
);
}
-export default function VersionInfo({ frontMatter }) {
- const { moodleVersion = null } = frontMatter;
+const guessMoodleVersion = (frontMatter, metadata) => {
+ if (frontMatter.moodleVersion) {
+ return frontMatter.moodleVersion;
+ }
+
+ if (metadata.version) {
+ if (metadata.version.match(/^(?\d+\.\d+)(?\.\d+)?/)) {
+ return metadata.version;
+ }
+ }
+ return undefined;
+};
+
+export default function VersionInfo({ frontMatter, metadata = {} }) {
+ const moodleVersion = guessMoodleVersion(frontMatter, metadata);
if (!moodleVersion) {
// No version number found.
@@ -208,6 +277,7 @@ export default function VersionInfo({ frontMatter }) {
const versionData = getVersion(moodleVersion);
if (!versionData) {
// No valid version data found.
+ // We don't know how to handle this version.
return null;
}
@@ -215,6 +285,8 @@ export default function VersionInfo({ frontMatter }) {
);
}