handle links correctly
This commit is contained in:
parent
218305dbfe
commit
a3775b87db
|
@ -2,5 +2,5 @@
|
|||
|
||||
|
||||
#+begin_archive
|
||||
@@html:<li>@@ @@html:<span class="archive-item"><span class="archive-date">@@ Jul 05, 2019 @@html:</span>@@ [[file:posts/2019-07-04-org-publish.org][org-publish]] @@html:</span>@@ @@html:</li>@@
|
||||
@@html:<li>@@ @@html:<span class="archive-item"><span class="archive-date">@@ jul 06, 2019 @@html:</span>@@ [[file:posts/2019-07-04-org-publish.org][Static blog with org-mode]] @@html:</span>@@ @@html:</li>@@
|
||||
#+end_archive
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
(setq publish-assets-dir (concat publish-dir "/assets"))
|
||||
(setq rss-dir base-dir)
|
||||
(setq publish-rss-dir publish-dir)
|
||||
(setq domainname "https://her.esy.fun")
|
||||
(setq org-publish-project-alist
|
||||
`(("orgfiles"
|
||||
:base-directory ,base-dir
|
||||
|
@ -108,7 +109,7 @@
|
|||
("rss"
|
||||
:base-directory ,rss-dir
|
||||
:base-extension "org"
|
||||
:html-link-home "https://her.esy.fun/"
|
||||
:html-link-home ,domainname
|
||||
:html-link-use-abs-url t
|
||||
:rss-extension "xml"
|
||||
:publishing-directory ,publish-rss-dir
|
||||
|
@ -119,6 +120,21 @@
|
|||
:table-of-contents nil)
|
||||
|
||||
("blog" :components ("orgfiles" "assets" "rss"))))
|
||||
|
||||
;; add target=_blank and rel="noopener noreferrer" to all links by default
|
||||
(defun my-org-export-add-target-blank-to-http-links (text backend info)
|
||||
"Add target=\"_blank\" to external links."
|
||||
(when (and
|
||||
(org-export-derived-backend-p backend 'html)
|
||||
(string-match "href=\"http[^\"]+" text)
|
||||
(not (string-match "target=\"" text))
|
||||
(not (string-match (concat "href=\"" domainname "[^\"]*") text)))
|
||||
(string-match "<a " text)
|
||||
(replace-match "<a target=\"_blank\" rel=\"noopener noreferrer\" " nil nil text)))
|
||||
|
||||
(add-to-list 'org-export-filter-link-functions
|
||||
'my-org-export-add-target-blank-to-http-links)
|
||||
|
||||
#+end_src
|
||||
|
||||
* Welcome!
|
||||
|
@ -129,3 +145,6 @@ This is a new take on my personal blog.
|
|||
With a lot more minimalism in mind.
|
||||
|
||||
With [[http://orgmode.org][org-mode]]
|
||||
|
||||
|
||||
TEST
|
||||
|
|
Loading…
Reference in a new issue