From fc978fa16b8379fb997dc3da5bf22c03ce2b632c Mon Sep 17 00:00:00 2001 From: StevenJoeZhang <1119186082@qq.com> Date: Wed, 6 Mar 2019 16:53:56 +0800 Subject: [PATCH 1/2] update --- _config.yml | 32 +++++++-------- layout/_third-party/pdf.swig | 78 +++++++++++++++--------------------- scripts/tags/pdf.js | 13 ++++++ 3 files changed, 59 insertions(+), 64 deletions(-) create mode 100644 scripts/tags/pdf.js diff --git a/_config.yml b/_config.yml index 12ef1106f7..3065fd214b 100644 --- a/_config.yml +++ b/_config.yml @@ -475,24 +475,6 @@ math: copy_tex_js: //cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.js copy_tex_css: //cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.css -# PDF Support -# Dependencies: https://github.com/theme-next/theme-next-pdf -pdf: - enable: false - - # Default (true) will load PDFObject / PDF.js script on demand. - # That is it only render those page which has `pdf: true` in Front Matter. - # If you set it to false, it will load PDFObject / PDF.js srcipt EVERY PAGE. - per_page: true - - height: 500px - - pdfobject: - # Use 2.1.1 as default, jsdelivr as default CDN, works everywhere even in China - cdn: //cdn.jsdelivr.net/npm/pdfobject@2.1.1/pdfobject.min.js - # CDNJS, provided by cloudflare, maybe the best CDN, but not works in China - #cdn: //cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js - # Han Support # Dependencies: https://github.com/theme-next/theme-next-han han: false @@ -807,6 +789,20 @@ tabs: labels: true border_radius: 0 +# PDF tag, requires two plugins: pdfObject and pdf.js +# pdfObject will try to load pdf files natively, if failed, pdf.js will be used. +# The following `cdn` setting is only for pdfObject, because cdn for pdf.js might be blocked by CORS policy. +# So, YOU MUST install the dependency of pdf.js if you want to use pdf tag and make it work on all browsers. +# See: https://github.com/theme-next/theme-next-pdf +pdf: + # Default height + height: 500px + pdfobject: + # Use 2.1.1 as default, jsdelivr as default CDN, works everywhere even in China + cdn: //cdn.jsdelivr.net/npm/pdfobject@2.1.1/pdfobject.min.js + # CDNJS, provided by cloudflare, maybe the best CDN, but not works in China + #cdn: //cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js + #! --------------------------------------------------------------- #! DO NOT EDIT THE FOLLOWING SETTINGS diff --git a/layout/_third-party/pdf.swig b/layout/_third-party/pdf.swig index 75445d032a..afd28b5e13 100644 --- a/layout/_third-party/pdf.swig +++ b/layout/_third-party/pdf.swig @@ -1,46 +1,32 @@ -{% if theme.pdf.enable %} - {% set is_index_has_pdf = false %} - - {# At home, check if there has `pdf: true` post #} - {% if is_home() %} - {% for post in page.posts %} - {% if post.pdf and not is_index_has_pdf %} - {% set is_index_has_pdf = true %} - {% endif %} - {% endfor %} - {% endif %} - - {% if not theme.pdf.per_page or (is_index_has_pdf or page.pdf) %} - - - - {% endif %} -{% endif %} + + diff --git a/scripts/tags/pdf.js b/scripts/tags/pdf.js new file mode 100644 index 0000000000..f9b5ce3cb7 --- /dev/null +++ b/scripts/tags/pdf.js @@ -0,0 +1,13 @@ +/** + * pdf.js | https://theme-next.org/docs/tag-plugins/pdf/ + */ + +/* global hexo */ + +'use strict'; + +function pdf(args) { + return `
`; +} + +hexo.extend.tag.register('pdf', pdf, {ends: false}); From 7b57115595c3d6dfcd5c1fd515c916d01981f798 Mon Sep 17 00:00:00 2001 From: StevenJoeZhang <1119186082@qq.com> Date: Wed, 6 Mar 2019 19:38:47 +0800 Subject: [PATCH 2/2] update --- _config.yml | 1 + layout/_third-party/pdf.swig | 2 ++ 2 files changed, 3 insertions(+) diff --git a/_config.yml b/_config.yml index 3065fd214b..a2375d645d 100644 --- a/_config.yml +++ b/_config.yml @@ -795,6 +795,7 @@ tabs: # So, YOU MUST install the dependency of pdf.js if you want to use pdf tag and make it work on all browsers. # See: https://github.com/theme-next/theme-next-pdf pdf: + enable: false # Default height height: 500px pdfobject: diff --git a/layout/_third-party/pdf.swig b/layout/_third-party/pdf.swig index afd28b5e13..06ed1333bc 100644 --- a/layout/_third-party/pdf.swig +++ b/layout/_third-party/pdf.swig @@ -1,3 +1,4 @@ +{% if theme.pdf.enable %}