此模块的文档可以在Module:Nav/doc创建
local p = {}
-- 标准面包屑导航条
function p.breadcrumbs(frame)
local output_text = {}
local title, showname
local pagename = frame.args[7] or ''
if pagename == '' then
pagename = mw.title.getCurrentTitle().text
end
output_text[#output_text+1] = '<ul class="cq_nav">'
output_text[#output_text+1] = '<li></li>'
output_text[#output_text+1] = '<li>[[首页|克鲁赛德战记WIKI]]</li>'
for i = 1,3 do
local title, showname
title = frame.args[i] or ''
showname = frame.args[i+3] or ''
if title ~= '' then
if showname == '' then
output_text[#output_text+1] = '<li>[['..title..']]</li>'
else
output_text[#output_text+1] = '<li>[['..title..'|'..showname..']]</li>'
end
else
break
end
end
output_text[#output_text+1] = '<li><b>'..pagename..'</b></li>'
output_text[#output_text+1] = '</ul>'
return table.concat(output_text)
end
-- 职业导航
function p.class(frame)
local output_text = {}
local page_type = frame.args[1] or ''
local current_name = frame.args[2] or ''
local page_name = mw.title.getCurrentTitle().text
local class_name = string.gsub(page_name, page_type, '')
local class_list = {{'剑士','Warrior'},{'骑士','Paladin'},{'猎人','Hunter'},{'弓手','Archer'},{'法师','Wizard'},{'祭司','Priest'}}
output_text[#output_text+1] = '<ul class="cq_class_nav" data-type="'..page_type..'">'
for key, class_data in ipairs(class_list) do
output_text[#output_text+1] = '<li'
if current_name == '' then
if ((class_name == class_data[1]) and class_name ~= '') then
output_text[#output_text+1] = ' class="current"'
end
else
if (current_name == class_data[1]) then
output_text[#output_text+1] = ' class="current force"'
end
end
output_text[#output_text+1] = '>[[File:'..class_data[2]..'_icon_m.png|link=]]<span class="class_name">'..class_data[1]..'</span></li>'
end
output_text[#output_text+1] = '</ul>'
return table.concat(output_text)
end
return p