feat: page links (#446)
This commit is contained in:
parent
4e2c8e74be
commit
455e23f22b
37
exampleSite/content/page/links/index.md
Normal file
37
exampleSite/content/page/links/index.md
Normal file
@ -0,0 +1,37 @@
|
||||
---
|
||||
title: Links
|
||||
links:
|
||||
- title: GitHub
|
||||
description: GitHub is the world's largest software development platform.
|
||||
website: https://github.com
|
||||
image: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
|
||||
- title: TypeScript
|
||||
description: TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
|
||||
website: https://www.typescriptlang.org
|
||||
image: ts-logo-128.jpg
|
||||
menu:
|
||||
main:
|
||||
weight: -50
|
||||
params:
|
||||
icon: link
|
||||
|
||||
comments: false
|
||||
---
|
||||
|
||||
To use this feature, add `links` section to frontmatter.
|
||||
|
||||
This page's frontmatter:
|
||||
|
||||
```yaml
|
||||
links:
|
||||
- title: GitHub
|
||||
description: GitHub is the world's largest software development platform.
|
||||
website: https://github.com
|
||||
image: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
|
||||
- title: TypeScript
|
||||
description: TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
|
||||
website: https://www.typescriptlang.org
|
||||
image: ts-logo-128.jpg
|
||||
```
|
||||
|
||||
`image` field accepts both local and external images.
|
BIN
exampleSite/content/page/links/ts-logo-128.jpg
Normal file
BIN
exampleSite/content/page/links/ts-logo-128.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
@ -15,6 +15,10 @@
|
||||
{{ define "main" }}
|
||||
{{ partial "article/article.html" . }}
|
||||
|
||||
{{ if .Params.links }}
|
||||
{{ partial "article/components/links" . }}
|
||||
{{ end }}
|
||||
|
||||
{{ partial "article/components/related-contents" . }}
|
||||
|
||||
{{ if not (eq .Params.comments false) }}
|
||||
|
26
layouts/partials/article/components/links.html
Normal file
26
layouts/partials/article/components/links.html
Normal file
@ -0,0 +1,26 @@
|
||||
<div class="article-list--compact links">
|
||||
{{ range $i, $link := .Params.links }}
|
||||
<article>
|
||||
<a href="{{ $link.website }}" target="_blank" rel="noopener">
|
||||
<div class="article-details">
|
||||
<h2 class="article-title">
|
||||
{{- $link.title -}}
|
||||
</h2>
|
||||
<footer class="article-time">
|
||||
{{ with $link.description }}
|
||||
{{ . }}
|
||||
{{ else }}
|
||||
{{ $link.website }}
|
||||
{{ end }}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
{{ with $link.image }}
|
||||
<div class="article-image">
|
||||
<img src="{{ . }}" loading="lazy">
|
||||
</div>
|
||||
{{ end }}
|
||||
</a>
|
||||
</article>
|
||||
{{ end }}
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user