-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Extend the built-in shortcodes #1594
Conversation
Should I squash everything into a single commit? |
No. These are fine as separate commits. |
I've looked at the I'm working on an enhancement. |
I've submitted PR #1597 to add a shortcode {{ if eq .ParamsType "position" }}
<div class="{{ if len .Params | eq 2 }}{{ .Get 1 }}{{ else }}youtube-container{{ end }}">
<iframe src="https://www.youtube.com/embed/{{ .Get 0 }}" allowfullscreen frameborder="0"></iframe>
</div>
{{ else }}
<div class="{{ if .Get "class" }}{{ .Get "class" }}{{ else }}youtube-container{{ end }}">
<iframe src="https://www.youtube.com/embed/{{ .Get "id" }}" allowfullscreen frameborder="0"></iframe>
</div>
{{ end }} Example references:
I like this approach because the user can control everything via SASS/CSS: .flex-video {
width: 560px;
height: 315px;
iframe {
width: 100%;
height: 100%;
}
} |
I had a look at this, too -- and having only inline style tags is not ideal. But it is the only way for a shortcode like this to be truly standalone. But they should be fallback options, somehow. |
@moorereason I know that inline style tags are an ugly way to add CSS code. But this is the only (as far as I know) for a shortcode to stay independent and to work out of the box. It was my intention that they take the full width of the layout and are responsive. With defaults, the user doesn't need to add any styling to achieve this. I like your approach to give users more flexibility to style the elements of the shortcode. |
I've updated PR #1597 to use a simple boolean, as @bep suggested. Since it doesn't sound like I'm going to win the style argument, here's an updated example: {{ if .IsNamedParams }}
<div {{ if .Get "class" }}class="{{ .Get "class" }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}>
<iframe src="https://www.youtube.com/embed/{{ .Get "id" }}" {{ if not (.Get "class") }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}allowfullscreen frameborder="0"></iframe>
</div>
{{ else }}
<div {{ if len .Params | eq 2 }}class="{{ .Get 1 }}"{{ else }}style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;"{{ end }}>
<iframe src="https://www.youtube.com/embed/{{ .Get 0 }}" {{ if len .Params | eq 1 }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" {{ end }}allowfullscreen frameborder="0"></iframe>
</div>
{{ end }} If you pass in a class name, we use that instead of the built-in style tags. The logic on the |
That I like. |
I've added the |
Looks good to me. Any comments @moorereason ? |
Does it matter we use On the twitter shortcode, I'd just send the tweet ID. The username is unnecessary:
|
I've made every shortcode protocol independent by just leaving the Now, the Twitter shortcode just requires the tweet's id. |
LGTM 👍 PS - @digitalcraftsman, I think you need to sign the new CLA. Hugo is now Apache 2.0 licensed! Yea! |
Done! Nice to see that @spf13 was finally able to make the transition. |
Good work. Merged in 311307c |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
See #1576.