Browse Source

Add option to show list of articles which mention article

master
Jan-Lukas Else 12 months ago
parent
commit
a5ce0e459d
  1. 2
      assets/css/style.scss
  2. 5
      i18n/de.yaml
  3. 5
      i18n/en.yaml
  4. 1
      layouts/_default/single.html
  5. 26
      layouts/partials/mentionedin.html

2
assets/css/style.scss

@ -779,7 +779,7 @@ select {
}
/* Related articles and webmentions */
.related, .mentions {
.related, .mentions, .mentionedin {
@include subarticle-element;
@media screen and (max-width: $break1) {
min-width: 100%;

5
i18n/de.yaml

@ -65,4 +65,7 @@
translation: Lies mir bitte vor.
- id: stopspeak
translation: Hör auf zu sprechen!
translation: Hör auf zu sprechen!
- id: mentionedin
translation: Erwähnt in

5
i18n/en.yaml

@ -68,4 +68,7 @@
translation: Read to me, please.
- id: stopspeak
translation: Stop speaking!
translation: Stop speaking!
- id: mentionedin
translation: Mentioned in

1
layouts/_default/single.html

@ -22,6 +22,7 @@
</div>
{{ partial "post_tags" . }}
</article>
{{ partial "mentionedin.html" . }}
{{ if (.Param "authorbox") }}{{ partialCached "authorbox" . }}{{ end }}
</main>
{{ if (and (.Param "promo") .CurrentSection.Parent) }}{{ partialCached "promo" . }}{{ end }}

26
layouts/partials/mentionedin.html

@ -0,0 +1,26 @@
{{ if .Param "mentionedin" }}
{{ if in (.Site.Param "postSections" | default (slice "posts")) .Type }}
{{ $mentionedIn := slice }}
{{ $current := .RelPermalink }}
{{ range .Sites }}
{{ $allPages := ( where .RegularPages "Type" "in" (.Param "postSections" | default (slice "posts")) ) }}
{{ range $allPages }}
{{ if strings.Contains .RawContent $current }}
{{ $mentionedIn = $mentionedIn | append . }}
{{ end }}
{{ end }}
{{ end }}
{{ with $mentionedIn }}
<div class="mentionedin">
<details>
<summary class="mentionedin-caption">{{ T "mentionedin" }}</summary>
<ul class="mentionedin-list">
{{ range sort . "Date" "desc" }}
<li><a href="{{ .RelPermalink }}">{{ with .Title }}{{ . }}{{ else }}{{ .Summary | truncate 60 }}{{ end }}</a> <i>{{.Date.Format ( .Site.Params.dateformat | default "January 02, 2006")}}</i></li>
{{ end }}
</ul>
</details>
</div>
{{ end }}
{{ end }}
{{ end }}
Loading…
Cancel
Save