Module:AfC topic

Revision as of 11:05, 15 September 2023 by WikiDwarf (talk | contribs) (Add)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local getArgs = require('Module:Arguments').getArgs

local p = {}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	local ns = mw.title.getCurrentTitle().namespace
	if ns ~= 118 and ns ~= 2 then
		return '[[Category:AfC topic used in wrong namespace]]'
	end
	
	local data = mw.loadJsonData('Bharatpedia:WikiProject Articles for creation/AfC topic map.json')
	
	local topic = args[1]
	local match = data[topic]
	
	if match ~= nil then
		return '[[Category:' .. match.category .. ']]'
	else 
		return '[[Category:AfC topic: invalid parameter]]'
	end
	
end

return p