Fix period generation

This commit is contained in:
Hans5958 2022-04-30 11:28:20 +07:00
parent 55bc870531
commit 8728ca1d1b
2 changed files with 8 additions and 4 deletions

View file

@ -43,7 +43,7 @@ function createInfoBlock(entry, isPreview) {
else {
let targetPeriod = formatPeriod(currentPeriod, currentPeriod, currentVariation)
linkElement.href = "#" + entry.id
if (targetPeriod) linkElement.href += "/" + targetPeriod
if (targetPeriod && targetPeriod != defaultPeriod) linkElement.href += "/" + targetPeriod
};
const linkNameElement = document.createElement("span");
linkNameElement.className = "flex-grow-1 text-break";

View file

@ -263,12 +263,16 @@ function parsePeriod(periodString) {
}
function formatPeriod(start, end, variation) {
let periodString
let periodString, variationString
variationString = variationsConfig[variation].code
if (start === end) {
if (start === variationsConfig[variation].default) periodString = ""
if (start === variationsConfig[variation].default && variation !== defaultVariation) {
periodString = ""
}
else periodString = start
}
else periodString = start + "-" + end
if (variation !== "default") return variationsConfig[variation].code + ":" + periodString
if (periodString && variationString) return variationsConfig[variation].code + ":" + periodString
if (variationString) return variationString
return periodString
}