Skip to content

Commit

Permalink
External post item support
Browse files Browse the repository at this point in the history
  • Loading branch information
LarssonOliver committed Oct 24, 2024
1 parent 99226f3 commit 5f8aee2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 7 additions & 2 deletions components/PostListItem.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<template>
<h2>
<h2 v-if="content.external">
<NuxtLink :to="content.externalUrl" target="_blank">
{{ content.title }}
</NuxtLink>
</h2>
<h2 v-else>
<NuxtLink :to="content._path">
{{ content.title }}
</NuxtLink>
</h2>
<span>{{ date }}</span>
<span>{{ content.external ? "External Post - " : "" }}{{ content.language ? `${content.language} - ` : "" }}{{ date }}</span>
<p>{{ content.description }}</p>
</template>

Expand Down
11 changes: 11 additions & 0 deletions content/testExternal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
draft: true
date: 2022-01-03
title: Test External
author: Oliver Larsson
description:
external: true
externalUrl: https://larssonoliver.com
language: Swedish
---

2 changes: 1 addition & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const page = ref(+(route.query.page || 1));
async function fetchData() {
const { data } = await useAsyncData(() => {
return queryContent<MarkdownParsedContent>()
.only(["title", "author", "date", "description", "_path"])
.only(["title", "author", "date", "description", "_path", "external", "externalUrl", "language"])
.sort({ date: -1 })
.skip(pageSize * (page.value - 1))
.limit(pageSize)
Expand Down

0 comments on commit 5f8aee2

Please sign in to comment.