Skip to content

Commit

Permalink
Remove built-in shortcodes
Browse files Browse the repository at this point in the history
Bazooka way of fixing #1832
  • Loading branch information
Keats committed Feb 16, 2023
1 parent 61570bb commit a56e424
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 94 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ for breaking changes with libsass: look for "beginning in Dart Sass"
- Merge settings for the default language set in the root of `config.toml` and in the `[languages.{default_lang}]` section.
This will error if 2 values are set
- Code blocks content are no longer included in the search index
- Remove built-ins shortcodes

This comment has been minimized.

Copy link
@didof

didof Feb 27, 2023

Why?

This comment has been minimized.

Copy link
@Keats

Keats Feb 27, 2023

Author Collaborator

The youtube one for example had been broken for a long time and no one really noticed. It's better to not have anything than something not tested/doesn't work. Most of them were only a couple of lines anyway.



### Other
Expand Down
3 changes: 0 additions & 3 deletions components/templates/src/builtins/shortcodes/gist.html

This file was deleted.

3 changes: 0 additions & 3 deletions components/templates/src/builtins/shortcodes/streamable.html

This file was deleted.

3 changes: 0 additions & 3 deletions components/templates/src/builtins/shortcodes/vimeo.html

This file was deleted.

10 changes: 0 additions & 10 deletions components/templates/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ pub static ZOLA_TERA: Lazy<Tera> = Lazy::new(|| {
include_str!("builtins/split_sitemap_index.xml"),
),
("__zola_builtins/anchor-link.html", include_str!("builtins/anchor-link.html")),
(
"__zola_builtins/shortcodes/youtube.html",
include_str!("builtins/shortcodes/youtube.html"),
),
("__zola_builtins/shortcodes/vimeo.html", include_str!("builtins/shortcodes/vimeo.html")),
("__zola_builtins/shortcodes/gist.html", include_str!("builtins/shortcodes/gist.html")),
(
"__zola_builtins/shortcodes/streamable.html",
include_str!("builtins/shortcodes/streamable.html"),
),
("internal/alias.html", include_str!("builtins/internal/alias.html")),
])
.unwrap();
Expand Down
83 changes: 14 additions & 69 deletions docs/content/documentation/content/shortcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ should not be used as argument names in shortcodes.

### Shortcodes without body

Simply call the shortcode as if it was a Tera function in a variable block. All the examples below are valid
calls of the YouTube shortcode.
Simply call the shortcode as if it was a Tera function in a variable block.

```md
Here is a YouTube video:
Expand Down Expand Up @@ -198,13 +197,12 @@ Every shortcode can access the current language in the `lang` variable in the co

You can then use it in your Markdown like so: `{{/* bookcover() */}}`

## Built-in shortcodes
## Examples

Zola comes with a few built-in shortcodes. If you want to override a default shortcode template,
simply place a `{shortcode_name}.html` file in the `templates/shortcodes` directory and Zola will
use that instead.
Here are some shortcodes for inspiration.

### YouTube

Embed a responsive player for a YouTube video.

The arguments are:
Expand All @@ -214,79 +212,26 @@ The arguments are:
- `class`: a class to add to the `<div>` surrounding the iframe
- `autoplay`: when set to "true", the video autoplays on load

Usage example:

```md
{{/* youtube(id="dQw4w9WgXcQ") */}}

{{/* youtube(id="dQw4w9WgXcQ", playlist="RDdQw4w9WgXcQ") */}}
Code:

{{/* youtube(id="dQw4w9WgXcQ", autoplay=true) */}}

{{/* youtube(id="dQw4w9WgXcQ", autoplay=true, class="youtube") */}}
```

Result example:

{{ youtube(id="dQw4w9WgXcQ") }}

### Vimeo
Embed a player for a Vimeo video.

The arguments are:

- `id`: the video id (mandatory)
- `class`: a class to add to the `<div>` surrounding the iframe

Usage example:

```md
{{/* vimeo(id="124313553") */}}

{{/* vimeo(id="124313553", class="vimeo") */}}
<div {% if class %}class="{{class}}"{% endif %}>
<iframe src="https://www.youtube-nocookie.com/embed/{{id}}{% if playlist %}?list={{playlist}}{% endif %}{% if autoplay %}?autoplay=1{% endif %}" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
```

Result example:

{{ vimeo(id="124313553") }}

### Streamable
Embed a player for a Streamable video.

The arguments are:

- `id`: the video id (mandatory)
- `class`: a class to add to the `<div>` surrounding the iframe

Usage example:

```md
{{/* streamable(id="92ok4") */}}
{{/* youtube(id="dCKeXuVHl1o") */}}

{{/* streamable(id="92ok4", class="streamble") */}}
```
{{/* youtube(id="dCKeXuVHl1o", playlist="RDdQw4w9WgXcQ") */}}

Result example:

{{ streamable(id="92ok4") }}

### Gist
Embed a [Github gist](https://gist.github.com).

The arguments are:

- `url`: the url to the gist (mandatory)
- `file`: by default, the shortcode will pull every file from the URL unless a specific filename is requested
- `class`: a class to add to the `<div>` surrounding the iframe

Usage example:

```md
{{/* gist(url="https://gist.github.com/Keats/e5fb6aad409f28721c0ba14161644c57") */}}
{{/* youtube(id="dCKeXuVHl1o", autoplay=true) */}}

{{/* gist(url="https://gist.github.com/Keats/e5fb6aad409f28721c0ba14161644c57", class="gist") */}}
{{/* youtube(id="dCKeXuVHl1o", autoplay=true, class="youtube") */}}
```

Result example:
### Image Gallery

{{ gist(url="https://gist.github.com/Keats/e5fb6aad409f28721c0ba14161644c57") }}
See [content processing page](@/documentation/content/image-processing/index.md#creating-picture-galleries) for code and example.
6 changes: 0 additions & 6 deletions test_site/content/posts/simple.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,3 @@ A simple page

{{ youtube(id="e1C9kpMV2e8") }}
{{ youtube(id="e1C9kpMV2e8", autoplay=true) }}

{{ vimeo(id="210073083") }}

{{ streamable(id="c0ic") }}

{{ gist(url="https://gist.github.com/Keats/32d26f699dcc13ebd41b") }}
File renamed without changes.

0 comments on commit a56e424

Please sign in to comment.