Sharing my shortcode for blockquotes

The project I’m currently working on requires attributed, semantically correct, quotations with fairly typical additions.

I had a quick look round couldn’t find anything that I would use, so rolled my own. Sharing here in case it is useful to anyone else.

If you have any questions, or see room for improvement, please do say. Thank you.

{{ if .Get "author" }}
  <figure{{ with .Get "cite" }} cite="https://{{.}}"{{ end }}>
    <blockquote itemscope itemtype="">
      <p itemprop="citation">{{ .Inner }}</p>
        <span itemprop="author" itemscope itemtype="">
          <span itemprop="name">{{ .Get "author" }}</span>
        {{ if .Get "role" }}
          <span itemprop="jobTitle">{{.Get "role" }}</span>
        {{ end }}
{{ end }}

Example usage:

{{< blockquote author="Tim Berners-Lee" cite="" role="Computer Scientist" >}}
The Semantic Web isn't inherently complex. The Semantic Web language, at its heart, is very, very simple. It's just about the relationships between things.
{{</ blockquote >}}

If you don’t supply an author, the structured markup makes no sense, so it intentionally outputs nothing. There’s no reason to not use markdown quotes at that point, IMO.

1 Like

Why then inquiring twice if Author is set?

1 Like

Good spot @chrillek! Many thanks. I updated my solution.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.