-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add multi author option to tutorials
- Loading branch information
1 parent
d90bc2f
commit 8553b42
Showing
8 changed files
with
90 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<template> | ||
<div class="flex w-auto items-center justify-normal"> | ||
<UAvatarGroup | ||
size="sm" | ||
:max="2" | ||
> | ||
<UAvatar | ||
v-for="(author, authIndex) in authorAvatars" | ||
:key="authIndex" | ||
:src="author.src" | ||
:alt="author.name" | ||
/> | ||
</UAvatarGroup> | ||
<span | ||
v-if="!withLinks" | ||
class="ml-3" | ||
> | ||
{{ authorNames }} | ||
</span> | ||
<span | ||
v-else | ||
class="ml-3" | ||
> | ||
<a | ||
v-for="(author, authIndex) in props.authors" | ||
:key="authIndex" | ||
:href="author.url" | ||
target="_blank" | ||
class="hover:underline" | ||
> | ||
{{ author.name }}{{ authIndex < props.authors.length - 1 ? ', ' : '' }} | ||
</a> | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
const props = defineProps({ | ||
authors: { | ||
type: Array<{ name: string; url: string; avatar: string }>, | ||
required: true, | ||
default: () => [], | ||
}, | ||
withLinks: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}); | ||
const authorNames = computed(() => { | ||
return props.authors.map((author) => author.name).join(', '); | ||
}); | ||
const authorAvatars = computed(() => { | ||
return props.authors.map((author) => ({ src: author.avatar, name: author.name })); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters