Jump to content

Module:ParentPage

From Kid Dancers Wiki

Documentation for this module may be created at Module:ParentPage/doc

local p = {}

function p.getParent(frame)
    local pagename = frame.args[1] or mw.title.getCurrentTitle().fullText
    local parent = pagename:match("^(.+)/[^/]+$")
    
    if parent then
        return parent
    else
        return ""
    end
end

function p.getParentName(frame)
    local pagename = frame.args[1] or mw.title.getCurrentTitle().fullText
    local parent = pagename:match("^(.+)/[^/]+$")
    
    if parent then
        -- Remove namespace prefix for display
        local displayName = parent:match("^[^:]+:(.+)$") or parent
        return displayName
    else
        return ""
    end
end

return p