Module:Pagelist

From ArchivesWiki

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

function links( frame )
	if frame.args.list == nil then
		return ''
	end
	local list = frame.args.list
	local items = mw.text.split( list, ';', true )
	local outItems = {}
	for i,item in pairs( items ) do
		if item ~= nil and item ~= '' then
			local itemIndex = #outItems + 1
			outItems[itemIndex] = '[[' .. item .. ']]'
			if frame.args.preload ~= nil then
				local title = mw.title.new( item )
				if title == nil or not title.exists then
					local editUrl = title:canonicalUrl( { action = 'edit', preload = 'Template:' .. frame.args.preload .. '/preload' } )
					-- Replace the link in outItems.
					outItems[itemIndex] = item .. ' ([' .. editUrl .. ' create])'
				end
			end
		end
	end
	return table.concat( outItems, " · " )
end

return {
	links = function( frame ) return links( frame ) end;
}