« Modèle:RecentArticlesButtons/item » : différence entre les versions
De Nefald
Autres actions
Page créée avec « <li> <span class="ext-recent-articles__button"> [[{{{1}}}]] </span> </li> » |
Aucun résumé des modifications Balise : Révoqué |
||
| Ligne 1 : | Ligne 1 : | ||
-- Modèle pour un bouton d'article récent (compatible Citizen) | |||
local p = {} | |||
function p.item(frame) | |||
</ | local args = frame:getParent().args | ||
local pageName = args[1] or "Page inconnue" | |||
local lastMod = args[2] or "" | |||
-- Détection de la page active | |||
local currentTitle = mw.title.getCurrentTitle().text | |||
local isActive = (pageName == currentTitle) and ' active' or '' | |||
-- Formatage de la date | |||
local formattedDate = "" | |||
if lastMod ~= "" then | |||
formattedDate = string.format( | |||
'<span class="date">%s</span>', | |||
mw.getContentLanguage():formatDate("d/m/Y", lastMod) | |||
) | |||
end | |||
return string.format( | |||
'<a href="/wiki/%s" class="dpl-bouton-article%s">%s%s</a>', | |||
mw.uri.encode(pageName, "PATH"), | |||
isActive, | |||
mw.text.nowiki(pageName), | |||
formattedDate | |||
) | |||
end | |||
return p | |||
Version du 8 novembre 2025 à 10:43
-- Modèle pour un bouton d'article récent (compatible Citizen) local p = {}
function p.item(frame)
local args = frame:getParent().args local pageName = args[1] or "Page inconnue" local lastMod = args[2] or ""
-- Détection de la page active local currentTitle = mw.title.getCurrentTitle().text local isActive = (pageName == currentTitle) and ' active' or
-- Formatage de la date
local formattedDate = ""
if lastMod ~= "" then
formattedDate = string.format(
'%s',
mw.getContentLanguage():formatDate("d/m/Y", lastMod)
)
end
return string.format(
'<a href="/wiki/%s" class="dpl-bouton-article%s">%s%s</a>',
mw.uri.encode(pageName, "PATH"),
isActive,
mw.text.nowiki(pageName),
formattedDate
)
end
return p