Module:Post

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

local p = {}

function p.isMainOrArchive( title )
	return title == 'Welcome' or string.match( title, '[0-9]+ archive' ) ~= nil
end

function p.main( frame )
	local args = frame.args or {}
	local currentPage = mw.title.getCurrentTitle().prefixedText
	local out = ''
	if mw.getCurrentFrame():getParent() ~= nil and not p.isMainOrArchive( currentPage ) then
		local cargoStore = '{{#cargo_store: _table=posts | '
			.. '| date     = ' .. ( args.date or '' )
			.. '| location = ' .. ( args.location or '' )
			.. '| timezone = ' .. ( args.timezone or '' )
			.. '| keywords = ' .. ( args.keywords or args.categories or '' )
			.. '| description = ' .. ( args.description or '' )
			.. '}}'
		local parentFrame = mw.getCurrentFrame():getParent()
		out = out
			.. parentFrame:preprocess( '<includeonly>' .. cargoStore .. '</includeonly>' )
			.. parentFrame:callParserFunction( '#seo', { '',
				 description = args.description or 'A blog post by Sam Wilson.',
				 keywords = ( args.keywords or args.categories or nil ),
				 author = 'Sam Wilson',
				 published_time = args.date or nil
			} ) 
	end
	return out
end

return p