Module:CategoryList: Difference between revisions

From Vintage Story Wiki
(Created page with "local p = {} function p.main(f) local args = require( 'Module:ProcessArgs' ).merge( true ) local title = mw.title.getCurrentTitle().baseText local preReleases = mw.sit...")
 
mNo edit summary
Line 6: Line 6:
local title = mw.title.getCurrentTitle().baseText
local title = mw.title.getCurrentTitle().baseText
local preReleases = mw.site.stats.pagesInCategory('Game_Versions', 'pages')
local preReleases = mw.site.stats.pagesInCategory(title .. 'pre-releases', 'pages')
local releaseCandidates = mw.site.stats.pagesInCategory(title .. 'release candidates', 'pages')
return preReleases
local links = ''
if preReleases > 0 then
links = links .. '<li>[[:Category:' .. title .. ' pre-releases|\'\'\'Pre-releases\'\'\' (' .. preReleases .. ')]]</li>'
end
if releaseCandidates > 0 then
links = links .. '<li>[[:Category:' .. title .. ' release candidates|\'\'\'Release candidates\'\'\' (' .. releaseCandidates .. ')]]</li>'
end
if preReleases > 0 or releaseCandidates > 0 then
  links = links .. '([[:Category:' .. title .. ' development versions|View all]])'
end
local body = '<ol style="list-style-type: none; margin: 0; padding: 0;">' .. links .. '</ol>'
return body
end
end
return p
return p

Revision as of 22:14, 27 August 2022

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

local p = {}

function p.main(f)
	local args = require( 'Module:ProcessArgs' ).merge( true )
	
	local title = mw.title.getCurrentTitle().baseText
	
	local preReleases = mw.site.stats.pagesInCategory(title .. 'pre-releases', 'pages')
	local releaseCandidates = mw.site.stats.pagesInCategory(title .. 'release candidates', 'pages')
	
	local links = ''
	if preReleases > 0 then
		links = links .. '<li>[[:Category:' .. title .. ' pre-releases|\'\'\'Pre-releases\'\'\' (' .. preReleases .. ')]]</li>'
	end
	if releaseCandidates > 0 then
		links = links .. '<li>[[:Category:' .. title .. ' release candidates|\'\'\'Release candidates\'\'\' (' .. releaseCandidates .. ')]]</li>'
	end
	
	if preReleases > 0 or releaseCandidates > 0 then
	   links = links .. '([[:Category:' .. title .. ' development versions|View all]])'
	end
	
	local body = '<ol style="list-style-type: none; margin: 0; padding: 0;">' .. links .. '</ol>'
	return body
end
return p