Jump to content

Module:ExternalLink

From Archono Database
Revision as of 08:17, 30 April 2026 by NonaSoft (talk | contribs)

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

local p = {}

p.GetTitle = function(frame)
    local webpage = frame.args[1]
    if not webpage then return "No link provided" end

    local data = mw.ext.externalData.getExternalData({  -- Requires External Data extension
        url = webpage,
        format = 'html'
    })

    local body = data[1] 
    
    if type(body) == 'string' then
        local body = data[1]
        local title = body:match("<title>(.-)</title>")
        return title or webpage
    else
        return "(debug outputting failed fetch:" .. body .. ")"
    end
end

return p