মডিউল:বিষয়শ্রেণী যুগল

উইকিপিডিয়া, মুক্ত বিশ্বকোষ থেকে
মডিউল নথি[তৈরি করুন]
require('Module:No globals')
local getArgs = require('Module:Arguments').getArgs
local hatnote = require('Module:Hatnote')._hatnote
local formatLink = require('Module:Format link')._formatLink

local p = {}

local catNS = mw.site.namespaces.Category.id -- category namespace number

-- Lua implementation of [[Template:CategoryPair]]
-- Arguments:
--   prevTitle -- mw.title.Title object for preceding category
--   nextTitle -- mw.title.Title object for succeeding category
-- Returns:
--   hatnote that says "see also" for one or both of prev/next (depending on whether they exist)
function p._pair(prevTitle, nextTitle)
	prevTitle = prevTitle and prevTitle.exists and formatLink{link = prevTitle.fullText}
	nextTitle = nextTitle and nextTitle.exists and formatLink{link = nextTitle.fullText}
	local note = ''
	if prevTitle and nextTitle then -- if both
		note = mw.ustring.format('এছাড়া পূর্ববর্তী %s ও পরবর্তী %s দেখুন',prevTitle, nextTitle)
	elseif prevTitle then -- if only prevTitle
		note = mw.ustring.format('এছাড়া পূর্ববর্তী %s দেখুন', prevTitle)
	elseif nextTitle then -- if only nextTitle
		note = mw.ustring.format('এছাড়া পরবর্তী %s দেখুন', nextTitle)
	else                  -- otherwise neither
		return mw.title.getCurrentTitle().namespace == catNS and '[[বিষয়শ্রেণী:আউটপুট বিহীন বিষয়শ্রেণী যুগল ব্যবহার করা পাতা]]' or ''
	end
	return hatnote(note, {extraclasses = 'seealso'})
end

function p.catPair(frame)
	local args = getArgs(frame, {wrappers={'টেমপ্লেট:বিষয়শ্রেণী যুগল'}})
	local prevTitle = args[1] and mw.title.new(args[1],catNS)
	local nextTitle = args[2] and mw.title.new(args[2],catNS)
	return p._pair(prevTitle, nextTitle)
end

function p.prevCat(frame)
	local args = getArgs(frame, {wrappers={'টেমপ্লেট:পূর্ববর্তী বিষয়শ্রেণী'}})
	local prevTitle = args[1] and mw.title.new(args[1], catNS)
	return p._pair(prevTitle, nil)
end

function p.nextCat(frame)
	local args = getArgs(frame, {wrappers={'টেমপ্লেট:পরবর্তী বিষয়শ্রেণী'}})
	local nextTitle = args[1] and mw.title.new(args[1], catNS)
	return p._pair(nil, nextTitle)
end

return p