in packages/docusaurus-plugin-content-docs/src/versions.ts [100:134]
export async function readVersionNames(
siteDir: string,
options: Pick<
PluginOptions,
'id' | 'disableVersioning' | 'includeCurrentVersion'
>,
): Promise<string[]> {
const versionFileContent = await readVersionsFile(siteDir, options.id);
if (!versionFileContent && options.disableVersioning) {
throw new Error(
`Docs: using "disableVersioning: ${options.disableVersioning}" option on a non-versioned site does not make sense.`,
);
}
const versions = options.disableVersioning ? [] : versionFileContent ?? [];
// We add the current version at the beginning, unless:
// - user don't want to; or
// - it's already been explicitly added to versions.json
if (
options.includeCurrentVersion &&
!versions.includes(CURRENT_VERSION_NAME)
) {
versions.unshift(CURRENT_VERSION_NAME);
}
if (versions.length === 0) {
throw new Error(
`It is not possible to use docs without any version. Please check the configuration of these options: "includeCurrentVersion: ${options.includeCurrentVersion}", "disableVersioning: ${options.disableVersioning}".`,
);
}
return versions;
}