%-------------------------------------
% Resume Pandoc Template
% Based on yuan-resume
% License: MIT
%------------------------------------

\documentclass[a4paper, 10pt]{article}

% Packages
\usepackage[top=1.2cm, bottom=2.6cm, left=1.8cm, right=2.3cm, marginparwidth=1.75cm]{geometry}
\usepackage{xcolor}
\usepackage{setspace}
\usepackage{titlesec}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{fontawesome}
\usepackage{hyperref}

% Font settings
\usepackage{fontspec}
% Try to use system fonts that are likely to be available
\setmainfont{Liberation Serif}[
  NFSSFamily=serif,
  UprightFont=*-Regular,
  BoldFont=*-Bold,
  ItalicFont=*-Italic,
  BoldItalicFont=*-BoldItalic,
  FallBack={DejaVu Serif}
]

% Emph style
\renewcommand{\emph}[1]{\textbf{\fontsize{11pt}{11pt}\selectfont #1}}

% Section styles
\titleformat{\section}{
  \setstretch{1.0}
  \scshape\raggedright
  \fontsize{14.5pt}{14.5pt}\selectfont 
}{}{0em}{}

% Define list environments
\newcommand{\itemListStart}{\begin{itemize}[itemsep=0pt]}
\newcommand{\itemListEnd}{\end{itemize}}

% Header
\begin{document}

\begin{flushright}
  \setstretch{0.8}
  $phone$\\
  $email$\\
  $for(links)$
  $links.icon$ \href{$links.url$}{$links.label$}\\
  $endfor$
\end{flushright}\vspace{-45pt}

\begin{flushleft}
  {\fontsize{30pt}{30pt}\selectfont \textsc{$name$}}
  \noindent\rule{\textwidth}{0.4pt}
  $location$
\end{flushleft}

% Sections from YAML
$for(sections)$
\section{$sections.title$}

$for(sections.entries)$
\begin{tabular}[t]{p{\textwidth}}
  \emph{$sections.entries.title$} $if(sections.entries.subtitle)$| \textit{$sections.entries.subtitle$}$endif$ \hfill $if(sections.entries.right)$$sections.entries.right$$endif$ \\
\end{tabular}

$if(sections.entries.bullets)$
\itemListStart
$for(sections.entries.bullets)$
  \item $sections.entries.bullets$
$endfor$
\itemListEnd
$endif$

$if(sections.entries.body)$
$sections.entries.body$
$endif$

$endfor$

$endfor$

\end{document} 