diff --git a/exampleSite/content/page/links/index.md b/exampleSite/content/page/links/index.md new file mode 100644 index 0000000..9e29bf3 --- /dev/null +++ b/exampleSite/content/page/links/index.md @@ -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. \ No newline at end of file diff --git a/exampleSite/content/page/links/ts-logo-128.jpg b/exampleSite/content/page/links/ts-logo-128.jpg new file mode 100644 index 0000000..85e3323 Binary files /dev/null and b/exampleSite/content/page/links/ts-logo-128.jpg differ diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 8b21c52..8ce42e9 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -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) }} diff --git a/layouts/partials/article/components/links.html b/layouts/partials/article/components/links.html new file mode 100644 index 0000000..118dbb3 --- /dev/null +++ b/layouts/partials/article/components/links.html @@ -0,0 +1,26 @@ +
+ {{ range $i, $link := .Params.links }} +
+ +
+

+ {{- $link.title -}} +

+
+ {{ with $link.description }} + {{ . }} + {{ else }} + {{ $link.website }} + {{ end }} +
+
+ + {{ with $link.image }} +
+ +
+ {{ end }} +
+
+ {{ end }} +
\ No newline at end of file