% Context file
% Filename: Test-headertexts.tex
% 
% 25-08-2022


\setuppagenumbering[alternative=doublesided,location=footer]

\setuppapersize[A5][A5]

\setuplayout
	[topspace=.6cm,
	 backspace=1.5cm,
	 header=2\bodyfontsize,
	 headerdistance=.5\bodyfontsize,
	 footer=1.2\bodyfontsize,
	 footerdistance=.5\bodyfontsize,
	 margin=0pt,
	 height=middle,
	 width=middle,
	 location=middle]
		
\startluacode
  thirddata      = thirddata or { }
  thirddata.diary = { }
  local diary     = thirddata.diary
	
  local report = logs.reporter("Test")

  function thirddata.diary.blocks(year)
	
	  report("Working in function: diary.blocks")
	  	
	  for i= 1,2 do
	  	local monthname = string.lower(os.date
	  	                  ("%B",os.time{year=year,month=i,day=1}))
	  	
	  	context.strut()
	  	
	  	context.setupheadertexts(
	  	  {function()
	  		  context("\\bf")
	  	    context(monthname)
	  		end},
	  		{function()
	  			context(year)
	  		end},
	  		{function()
	        context("\\bf")
          context(monthname)
	  		end},
	  	  {function()
	  			  context(year)
	  		end})
	  	for i = 1,20 do
	  				context.input("ward")
						context.crlf()
	  	end
	  end
  end
\stopluacode

\define[1]\Test{\ctxlua{thirddata.diary.blocks(#1)}}

\starttext
  \strut 
  \Test{2022}
\stoptext