Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support For Multiple Embeds #29

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,23 @@ cp ./layouts/shortcodes/embed-pdf.html /path/to/your/hugo/website/layouts/shortc
```
<br />

3. Copy the pdf.js library files from `./static/js/pdf-js` to `./static/js` in your Hugo website directory.
3. Copy the file `./layouts/partials/embed-pdf-dependencies.html` to `./layouts/partials` in your Hugo website directory.
<br />

```shell
cp ./layouts/partials/embed-pdf-dependencies.html /path/to/your/hugo/website/layouts/partials
```
<br />

4. Add the `embed-pdf-dependencies.html` partial to your theme.

You'll want to add the following line to a layout in your `partials` directory responsible for generating the `<head>` section of your blog. This will include the JavaScript dependencies and CSS styles for the `hugo-embed-pdf` shortcode exactly once on pages that use it.

```
{{ partial "embed-pdf-dependencies.html" . }}
```

5. Copy the pdf.js library files from `./static/js/pdf-js` to `./static/js` in your Hugo website directory.
<br />

**Note:** If you do not have a `./static/js` directory you can create it.
Expand Down
51 changes: 51 additions & 0 deletions layouts/partials/embed-pdf-dependencies.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{ if .HasShortcode "embed-pdf" }}
<script type="text/javascript" src='{{"/" | relURL}}/js/pdf-js/build/pdf.js'></script>

<style>
/* PDF embed shortcode */
.pdf-canvas {
border: 1px solid black;
direction: ltr;
width: 100%;
height: auto;
display: none;
}

.pdf-paginator {
display: none;
text-align: center;
margin-top: 10px;
margin-bottom: 10px;
}

.pdf-source {
margin-left: 10px;
}

.pdf-loadingWrapper {
display: none;
justify-content: center;
align-items: center;
width: 100%;
height: 350px;
}

.pdf-loading {
display: inline-block;
width: 50px;
height: 50px;
border: 3px solid #d2d0d0;;
border-radius: 50%;
border-top-color: #383838;
animation: pdf-spin 1s ease-in-out infinite;
-webkit-animation: spin 1s ease-in-out infinite;
}

@keyframes pdf-spin {
to { -webkit-transform: rotate(360deg); }
}
@-webkit-keyframes pdf-spin {
to { -webkit-transform: rotate(360deg); }
}
</style>
{{ end }}
Loading