diff --git a/ox-hugocv.el b/ox-hugocv.el index f0797f9..4a8057c 100644 --- a/ox-hugocv.el +++ b/ox-hugocv.el @@ -47,9 +47,6 @@ (:homepage "HOMEPAGE" nil nil parse) (:address "ADDRESS" nil nil newline) (:photo "PHOTO" nil nil parse) - (:gitlab "GITLAB" nil nil parse) - (:github "GITHUB" nil nil parse) - (:linkedin "LINKEDIN" nil nil parse) (:with-email nil "email" t t) ) :translate-alist '((headline . org-hugocv-headline) @@ -80,6 +77,42 @@ as a communication channel." contents))) +(defun social-entry (icon url handle) + (let* ((nw-handle (string-trim handle)) + (icon-wrap (if (org-string-nw-p icon) (concat (format " " icon) "%s") "%s")) + (link-wrap (format "%s" url nw-handle icon-wrap)) + + ) + (format link-wrap nw-handle))) + +(defun org-hugocv--format-socialchannels (headline contents info) + (let* ((channel (downcase (org-export-data (org-element-property :title headline) info))) + + (entry (-any (lambda (network) (when (string-match-p channel (plist-get network :url)) + (social-entry (plist-get network :icon) (plist-get network :url) contents))) + '((:url "https://www.github.com" :icon "fa-github") + (:url "https://www.gitlab.com" :icon "fa-gitlab") + (:url "https://www.linkedin.com/in" :icon "fa-linkedin") + (:url "https://www.linkedin.com/in" :icon "fa-linkedin") + (:url "https://twitter.com" :icon "fa-twitter") + (:url "https://facebook.com" :icon "fa-facebook") + (:url "https://www.instagram.com" :icon "fa-instagram")) + + ))) + + (cond + (entry entry) + ((org-element-property :URL headline) + (let ((icon (org-export-data (org-element-property :ICON headline) info)) + (url (org-export-data (org-element-property :URL headline) info)) + (handle (org-export-data contents info)) + ) + (concat (if (org-string-nw-p icon) + "" + (concat (org-export-data (org-element-property :title headline) info) " : ")) + (social-entry icon url handle)))) + ((org-export-with-backend 'hugo headline contents info))) + )) ;;;; Headline (defun org-hugocv-headline (headline contents info) @@ -87,12 +120,14 @@ contents))) CONTENTS is the contents of the headline. INFO is a plist used as a communication channel." (unless (org-element-property :footnote-section-p headline) - (let ((environment (let ((env (org-element-property :CV_ENV headline))) + (let ((environment (let ((env (org-export-get-category headline info))) (or (org-string-nw-p env) "block")))) (cond ;; is a cv entry ((equal environment "cventry") (org-hugocv--format-cventry headline contents info)) + ((equal environment "social") + (org-hugocv--format-socialchannels headline contents info)) ((org-export-with-backend 'hugo headline contents info)))))) (defun org-hugocv-inner-template (contents info) @@ -108,25 +143,6 @@ holding export options." ;; homepage (let ((homepage (org-export-data (plist-get info :homepage) info))) (when (org-string-nw-p homepage) (format "
  • %s
  • \n" homepage homepage))) - ;; social media - (mapconcat (lambda (social-network) - - (let ((network (org-export-data - (plist-get info (car social-network)) - - info))) - - (when (org-string-nw-p network) - (format "
  • %s
  • \n" - (nth 1 social-network) - (nth 2 social-network) - network - network)))) - - '((:github "github" "www.github.com") - (:gitlab "gitlab" "www.gitlab.com") - (:linkedin "linkedin" "www.linkedin.com/in")) - "") "\n\n" (org-hugo-inner-template contents info)))