making my own article-link partial
This commit is contained in:
		
							parent
							
								
									9dbd3ff379
								
							
						
					
					
						commit
						af362f436d
					
				
					 3 changed files with 203 additions and 128 deletions
				
			
		
							
								
								
									
										81
									
								
								layouts/partials/article-link.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								layouts/partials/article-link.html
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,81 @@
 | 
			
		|||
 | 
			
		||||
{{ $articleClasses := "flex flex-wrap article" }}
 | 
			
		||||
{{ if .Site.Params.list.showCards }}
 | 
			
		||||
{{ $articleClasses = delimit (slice $articleClasses "border" "border-neutral-200 dark:border-neutral-700 border-2 rounded-xl") " thumbnailshadow " }}
 | 
			
		||||
{{ end }}
 | 
			
		||||
 | 
			
		||||
{{ $articleImageClasses := "w-10px md:w-1/3 h-full object-cover thumbnail nozoom" }}
 | 
			
		||||
{{ if .Site.Params.list.showCards }}
 | 
			
		||||
{{ $articleImageClasses = delimit (slice $articleImageClasses "rounded-lg") " " }}
 | 
			
		||||
{{ else }}
 | 
			
		||||
{{ $articleImageClasses = delimit (slice $articleImageClasses "thumbnailshadow md:mr-7") " " }}
 | 
			
		||||
{{ end }}
 | 
			
		||||
 | 
			
		||||
{{ $articleInnerClasses := "" }}
 | 
			
		||||
{{ if .Site.Params.list.showCards }}
 | 
			
		||||
{{ $articleInnerClasses = delimit (slice $articleInnerClasses "p-4") " " }}
 | 
			
		||||
{{ else }}
 | 
			
		||||
{{ $articleInnerClasses = delimit (slice $articleInnerClasses "mt-3 md:mt-0") " " }}
 | 
			
		||||
{{ end }}
 | 
			
		||||
 | 
			
		||||
{{ with .Params.externalUrl }}
 | 
			
		||||
<a class="{{ $articleClasses }}" href="{{ . }}" target="_blank" rel="external">
 | 
			
		||||
  {{ else }}
 | 
			
		||||
  <a class="{{ $articleClasses }}" href="{{ .RelPermalink }}">
 | 
			
		||||
    {{ end }}
 | 
			
		||||
    {{- with $.Params.images -}}
 | 
			
		||||
    {{- range first 6 . }}
 | 
			
		||||
    <meta property="og:image" content="{{ . | absURL }}" />{{ end -}}
 | 
			
		||||
    {{- else -}}
 | 
			
		||||
    {{- $images := $.Resources.ByType "image" -}}
 | 
			
		||||
    {{- $featured := $images.GetMatch "*feature*" -}}
 | 
			
		||||
    {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
 | 
			
		||||
    {{- with $featured -}}
 | 
			
		||||
    {{ with .Resize "600x" }}
 | 
			
		||||
    <div class="{{ $articleImageClasses }}">
 | 
			
		||||
      <image class="{{ $articleImageClasses }} object-scale-down" src="{{ .RelPermalink }}"></image>
 | 
			
		||||
    </div>
 | 
			
		||||
    {{ end }}
 | 
			
		||||
    {{- else -}}
 | 
			
		||||
    {{- with $.Site.Params.images }}
 | 
			
		||||
    <meta property="og:image" content="{{ index . 0 | absURL }}" />{{ end -}}
 | 
			
		||||
    {{- end -}}
 | 
			
		||||
    {{- end -}}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    <div class="{{ $articleInnerClasses }}">
 | 
			
		||||
      <div class="items-center text-xl font-semibold">
 | 
			
		||||
        {{ with .Params.externalUrl }}
 | 
			
		||||
        <div>
 | 
			
		||||
          <div
 | 
			
		||||
            class="text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral">
 | 
			
		||||
            {{ $.Title | emojify }}
 | 
			
		||||
            <span class="text-xs align-top cursor-default text-neutral-400 dark:text-neutral-500">
 | 
			
		||||
              <span class="rtl:hidden">↗</span>
 | 
			
		||||
              <span class="ltr:hidden">↖</span>
 | 
			
		||||
            </span>
 | 
			
		||||
          </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        {{ else }}
 | 
			
		||||
        <div class="text-neutral-800 decoration-primary-500 hover:underline hover:underline-offset-2 dark:text-neutral"
 | 
			
		||||
          href="{{ .RelPermalink }}">{{ .Title | emojify }}</div>
 | 
			
		||||
        {{ end }}
 | 
			
		||||
        {{ if and .Draft .Site.Params.article.showDraftLabel }}
 | 
			
		||||
        <div class=" ltr:ml-2 rtl:mr-2">
 | 
			
		||||
          {{ partial "badge.html" (i18n "article.draft" | emojify) }}
 | 
			
		||||
        </div>
 | 
			
		||||
        {{ end }}
 | 
			
		||||
        {{ if templates.Exists "partials/extend-article-link.html" }}
 | 
			
		||||
        {{ partial "extend-article-link.html" . }}
 | 
			
		||||
        {{ end }}
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="text-sm text-neutral-500 dark:text-neutral-400">
 | 
			
		||||
        {{ partial "article-meta.html" . }}
 | 
			
		||||
      </div>
 | 
			
		||||
      {{ if .Params.showSummary | default (.Site.Params.list.showSummary | default false) }}
 | 
			
		||||
      <div class="py-1 prose dark:prose-invert">
 | 
			
		||||
        {{ .Summary | emojify }}
 | 
			
		||||
      </div>
 | 
			
		||||
      {{ end }}
 | 
			
		||||
    </div>
 | 
			
		||||
  </a>
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue