
\usemodule[visual]
\showgrid

\def\ColWidth{57mm}

\setuplayout[
    backspace=21mm,
    topspace=11mm,
    width=118mm,
    height=270mm,
    %header=9pt,
    %headerdistance=12pt,
    %footer=24pt,
    %footerdistance=0pt,
    rightmargindistance=4mm,
    rightmargin=\ColWidth,
    leftmargindistance=4mm,
    leftmargin=0mm,
    grid=yes,
    location=doublesided,
]

\setupbodyfont[9pt]
\setupinterlinespace[line=12pt]
% \definebodyfontenvironment[6pt][interlinespace=8pt]
% \definebodyfontenvironment[9pt][interlinespace=12pt]
% \definebodyfontenvironment[10pt][interlinespace=12pt]
% \definebodyfontenvironment[12pt][interlinespace=15pt]
% \definebodyfontenvironment[28pt][interlinespace=36pt]
% \definebodyfontenvironment[30pt][interlinespace=36pt]

\definefont[ChapterTitleFont][Serif*default at 30pt][36pt]
\definefont[SectionTitleFont][Serif*default at 9pt][12pt]
\definefont[FootnoteFont][Serif*default at 6pt][8pt]

\setupmargindata[inmargin][location=right,stack=continue,align=flushright,style={\FootnoteFont\setcharacterkerning[footnotes]}] %,style={\ss\tfx}]
\setupmargindata[inouter][location=right,stack=continue,align=flushright,style={\FootnoteFont\setcharacterkerning[footnotes]}]

\def\MarginNote#1{\inmargin[
  width=\ColWidth,
  align=flushleft,
  style={\FootnoteFont},
]{%
  \inframed[
    width=\ColWidth,
    align=right,
    frame=off,
    offset=overlay,
    strut=yes,
    ]{#1}%
  }%
}

\define\PlaceFootnote{%
  \inmargin[width=\ColWidth]{%
  \vtop{\placelocalnotes[footnote][before=,after=]}}}

\def\FNo#1{{\FootnoteFont#1\quad\gobblespacetokens}} %\crlf}} % Abstand geht nicht weg!?

\setupnote[footnote]
  [location=text,
   bodyfont=,
   indenting=no,
   before={\noindentation},
   next=\PlaceFootnote]
\setupnotation[footnote][ % footnote text
	way=bychapter,
	align=flushleft,
  style={\FootnoteFont},
  indenting=no,
  location=serried,
  alternative=serried,
  width=broad,
  numbercommand=\FNo,
]
\setuptexttexts[margin][][% "foot"note placement
  {\framed[
    align={flushright,bottom},
    frame=off,
    height=\textheight,
    width=\ColWidth,
  ]{%
    \strut\vfill\placenotes[footnote]}%
}]


\starttext

\dorecurse{20}{%
  \fakewords{5}{50}\footnote{\fakewords{10}{30}}
  \fakewords{5}{50}\footnote{\fakewords{5}{30}}
  \fakewords{5}{50}\par
}

\stoptext
