% chapter titling should look like:

%
% Chapter title           subtitle
%                         subtitle
%                         in the margin
%
% here starts the text
%
%

% table of contents should look like:

% Author Name
% Chapter title                 123
% subtitle


\usemodule[visual]

\setuplayout[
    backspace=21mm,
    topspace=12mm,
    width=117mm,
    height=270mm,
    header=15mm,
    headerdistance=2mm,
    footer=5mm,
    footerdistance=4mm,
    rightmargindistance=5mm,
    rightmargin=55mm,
    leftmargindistance=5mm,
    leftmargin=55mm,
    %leftmargin=0mm,
    outermargindistance=5mm,
    outermargin=55mm,
    innermargin=0mm,
    grid=yes,
    location=doublesided,
]
\setuppagenumbering[alternative=doublesided]
\setupalign[flushleft,hz,hanging]

\definebodyfontenvironment[9pt][interlinespace=4mm]
\definebodyfontenvironment[12pt][interlinespace=5mm]
\setupbodyfontenvironment[default][em=italic]
\definehighlight[emph][style=\em]
\definefont[ChapterTitleFont][Serif at 28pt][10mm]
\definefont[SectionTitleFont][Serif at 10pt][4mm]

\setupindenting[yes, 2.5em, first] %, next]

\definelayer[rightmargin][
        x=122mm,y=5mm,
        width=\outermarginwidth,height=\textheight]

\setupbackgrounds[text][background=rightmargin,state=start]


\setuphead[
  align={flushleft,nothyphenated},
	tolerance=verytolerant,
	grid=line,
	number=no]

\setupheadertexts[][part]
\define[2]\PartCmd{\relax} % part is only used as rubric
\setuphead[part][
  placehead=yes,
  location=none,
  page=no,
  number=no,
  command=\PartCmd,
]

\startsetups Subtitle
  \switchtobodyfont[rm,12pt]
\stopsetups

\define[2]\ChapterCmd{%
  \framed[width=\textwidth,frame=off,align=flushleft,style=\ChapterTitleFont]{#2}% without framed it’s a hbox?
  \setlayerframed[rightmargin]%
  [frame=off,width=\outermarginwidth,y=0mm,setups=Subtitle,align=flushleft]%
  {\structureuservariable{subtitle}}
}
\setuphead[chapter][
  page=right,
  style={\ChapterTitleFont},
  interlinespacing=10mm,
  grid=both,
  before={},
  command=\ChapterCmd,
  ]

\setuphead[section][
  page=no,
  style={\tf},
  before={\blank[small]\testpage[4]},
  after={\blank[small]},
  ]


% Table of contents

\define[1]\ChapterTocEntry{%
  \doifnotempty{%
    \structurelistuservariable{author}%
    }{%
    \structurelistuservariable{author}\crlf%
    }#1\doifnotempty{%
    \structurelistuservariable{subtitle}%
    }{%
    \crlf\structurelistuservariable{subtitle}%
    }%
  }
\setuplist[chapter][%
  margin=2em,
  textcommand=\ChapterTocEntry]

\starttext

\placelist[part,chapter][criterium=all]

\startpart[title={My Rubric}]

\dorecurse{3}{
  \startchapter[title={C \fakewords{2}{10}}]%
  [subtitle={S \fakewords{5}{10}},author={A\fakewords{2}{3}}]

    \fakewords{10}{100}

    \dorecurse{3}{
    \startsection[title={S \fakewords{1}{10} \recurselevel}]
      \fakewords{10}{300}

    \stopsection}

  \stopchapter}

\startchapter[title={Without author and subtitle}]

\input zapf

\stopchapter

\stoppart

\stoptext
