Module:Key people

From Omniversalis

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

--[[
-- This module produces a "See also: a, b and c" link. It implements the
-- template {{key people}}.
--]]

local mHatnote = require('Module:Hatnote')
local mSeeAlso = require('Module:See also')
local mArguments -- lazily initialise

local p = {}

function p.keyPeople(frame)
	mArguments = require('Module:Arguments')
	local args = mArguments.getArgs(frame, {parentOnly = true})
	local pages = {}
	for k, v in pairs(args) do
		if type(k) == 'number' then
			local display = args['label ' .. k] or args['l' .. k]
			local page = display and
				string.format('%s|%s', string.gsub(v, '|.*$', ''), display) or v
			pages[#pages + 1] = page
		end
	end
	if not pages[1] then
		return mHatnote.makeWikitextError(
			'no page names specified',
			'Template:key people#Errors',
			args.category
		)
	end
	local options = {
		altphrase = args.altphrase or 'Key people',
		selfref = args.selfref
	}
	return mSeeAlso._seeAlso(pages, options)
end

function p._keyPeople (pages, options)
	if not options.altphrase then options.altphrase = 'Key people' end
	return mSeeAlso._seeAlso(pages, options)
end

--legacy aliases
p.seealso = p.keyPeople
p._seealso = p._keyPeople

return p