Документацію для цього модуля можна створити у Модуль:TournamentNav/документація

local p = {}

local tournament_order = {
    "Перший сезон",
    "Другий сезон",
    "Третій сезон",
    "Четвертий сезон",
    "П'ятий сезон",
    "Шостий сезон",
    "Сьомий сезон",
    "Восьмий сезон",
    "Дев'ятий сезон",
    "Фінал Року"
}

local function find_tournament_index(tournament_name)
    for i, name in ipairs(tournament_order) do
        if name == tournament_name then
            return i
        end
    end
    return nil
end

function p.prevLink(frame)
    local current_tournament = frame.args[1] or mw.title.getCurrentTitle().text
    
    -- DEBUG: покажемо що передається
    if not find_tournament_index(current_tournament) then
        return '<span style="color:red;" title="' .. current_tournament .. '">← (DEBUG: ' .. current_tournament .. ')</span>'
    end
    
    local index = find_tournament_index(current_tournament)
    local prev_index = index == 1 and #tournament_order or index - 1
    local prev_tournament = tournament_order[prev_index]
    
    return '[[' .. prev_tournament .. '|←]]'
end

function p.nextLink(frame)
    local current_tournament = frame.args[1] or mw.title.getCurrentTitle().text
    
    -- DEBUG: покажемо що передається
    if not find_tournament_index(current_tournament) then
        return '<span style="color:red;" title="' .. current_tournament .. '">→ (DEBUG: ' .. current_tournament .. ')</span>'
    end
    
    local index = find_tournament_index(current_tournament)
    local next_index = index == #tournament_order and 1 or index + 1
    local next_tournament = tournament_order[next_index]
    
    return '[[' .. next_tournament .. '|→]]'
end

return p