Skip to content

Commit 8009ad4

Browse files
committed
Fix post template to render links from frontmatter
- Add links field to frontmatter destructuring - Add Links section to display external links - Links open in new tab with proper security attributes
1 parent 8ef42df commit 8009ad4

File tree

1 file changed

+16
-0
lines changed
  • gatsby-theme-academic/src/templates/post

1 file changed

+16
-0
lines changed

gatsby-theme-academic/src/templates/post/post.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const Post = ({ data }) => {
3838
date,
3939
commit,
4040
type,
41+
links,
4142
},
4243
tableOfContents,
4344
} = data.mdx;
@@ -139,6 +140,21 @@ const Post = ({ data }) => {
139140
</FlexboxGrid.Item>
140141
) : null}
141142
</FlexboxGrid>
143+
144+
{links && links.length > 0 && (
145+
<div style={{ marginBottom: '1rem' }}>
146+
<h4>Links</h4>
147+
<ul>
148+
{links.map((link, index) => (
149+
<li key={index}>
150+
<a href={link.url} target="_blank" rel="noopener noreferrer">
151+
{link.name}
152+
</a>
153+
</li>
154+
))}
155+
</ul>
156+
</div>
157+
)}
142158

143159
{state.locked
144160
? (

0 commit comments

Comments
 (0)