Módulo:EnlaceWikidata
A
local p = {}
function p.main(frame)
local args = frame.args
-- Soporte para argumentos posicionales (desde plantilla) o nombrados
local id = args.id or args[1]
local label = args.label or args[2]
if not id or id == '' then
return ''
end
id = mw.text.trim(id)
-- Si no se pasa etiqueta, usamos el propio ID
if not label or label == '' then
label = id
end
-- Detectar si es Propiedad (P) o Ítem (Q)
local prefix = string.sub(id, 1, 1):upper()
local url
if prefix == 'P' then
url = 'https://www.wikidata.org/wiki/Property:' .. id
else
-- Asumimos Q o ID numérico directo
url = 'https://www.wikidata.org/wiki/' .. id
end
return string.format('[%s %s]', url, label)
end
return p