Hopp til innhold

Modul:AutoDefaultsort

Fra Wikipedia, den frie encyklopedi
Sideversjon per 4. mar. 2025 kl. 22:58 av Løken (diskusjon | bidrag) (ny)
(diff) ← Eldre sideversjon | Nåværende sideversjon (diff) | Nyere sideversjon → (diff)
Moduldokumentasjon
local p = {}

function p.autoDefaultSort(frame)
    local title = mw.title.getCurrentTitle().text  -- Get the page title
    local words = mw.text.split(title, " ")       -- Split into words

    if #words > 1 then
        local lastname = words[#words]              -- Last word as last name
        local firstname = table.concat(words, " ", 1, #words - 1) -- Rest as first name
        return "{{DEFAULTSORT:" .. lastname .. ", " .. firstname .. "}}"
    else
        return "{{DEFAULTSORT:" .. title .. "}}"
    end
end

return p