%
% lectureslides 
% version 1.0
% 2022/03/01
%
% Taihao Zhang (taihao.de)
% 1 March, 2022
%
% This work is licensed under the Creative Commons Attribution 4.0 International License. 
% To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ 
% or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
%
% For contribution or suggestions, please contact me at t@taihao.de
%

\newcommand{\thispackage}{lectureslides}

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{\thispackage}[2022/03/01 \thispackage]

\RequirePackage{xparse}
\RequirePackage{pdfpages
    , tocloft
    , hyperref
    , babel
}
\renewcommand{\cftdot}{}
\renewcommand{\cftsecfont}{\mdseries}
\renewcommand{\cftsecafterpnum}{\vspace{-3.25mm}}

% Not really a variable meant to be changed, leaving it in for now
\newcommand*{\toclevel}{section}

\newcommand{\orientation}{, landscape}
\DeclareOption{portrait}{\renewcommand{\orientation}{}}
\DeclareOption{landscape}{\renewcommand{\orientation}{, landscape}}
\DeclareOption*{\PackageWarning{\thispackage}{Unknown option ‘\CurrentOption’}}
\ProcessOptions\relax

\newcommand{\createdAt}[1]{Compiled \today.}

\NewDocumentCommand{\course}{o m}{%
  {%
      \noindent\LARGE\bfseries\sffamily #2%
      \footnote{
          \IfNoValueTF{#1}%
            {
                % No optional argument passed
                \iflanguage{ngerman}{
                    Zusammengestellt am \today.
                }{
                    Compiled \today.
                }
            }%
            {#1}%
        }%
      \par%
  }%
}

\newcommand{\tocline}[1]{\arabic{\toclevel}.~#1}

\newcommand*{\lecturetitle}[1]{%
    \addtocounter{\toclevel}{1}%
    \newpage\phantomsection%
    \addcontentsline{toc}{\toclevel}{\tocline{#1}}%
}

\NewDocumentCommand{\lectureslides}{o o m}{%
    \includepdf[pages=#1-#2 \orientation]{#3}
    % \IfNoValueTF{#1}%
    % {\includepdf[pages=- \orientation]{#2}}%
    % {\includepdf[pages=-#1 \orientation]{#2}}%
}

\NewDocumentCommand{\lecture}{m o o m}{%
    \lecturetitle{#1}\lectureslides[#2][#3]{#4}%
}