% Context file
% filename: test.tex
% How to setup a CLD as a doublsided docuemnt with headers on odd and even pages...

\setuppagenumbering[alternative=doublesided]

\setuplayout
	[topspace=15mm,
	 backspace=15mm,
	 width=150mm,
	 height=middle]

% the following lua-code is in the actual project in a separate lua file.
\startluacode
function year_of_monthtables(year) --in project: thirddata.diary 	

  for i= 1,4 do	
		local monthname = string.lower(os.date
		                  ("%B",os.time{year=year,month=i,day=1}))

		context.setupheadertexts({
		  function()
			  context("\\bf")
		    context.labeltext(monthname)
				context("\\hfill")
				context(year)
			end},
		  {function()
			  context("\\bf")
		    context.labeltext(monthname)
				context("\\hfill")
				context(year)
			end})
		context.strut()
		context.bTABLE({"split=yes"})
  		for day =1,50 do
        context.bTR()
			    context.bTD()
		        context("This is a test page")
  		    context.eTD()
			  context.eTR()
			end
		context.eTABLE()
		context.page()
	end
end
\stopluacode

\define[1]\Test{\ctxlua{year_of_monthtables(#1)}}

\starttext
\Test{2022}
\stoptext   	