Skip to content

Commit

Permalink
feat: add multi author option to tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
itsacoyote committed May 6, 2024
1 parent d90bc2f commit 8553b42
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 43 deletions.
57 changes: 57 additions & 0 deletions components/content/AuthorsList.vue
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>
11 changes: 7 additions & 4 deletions content/tutorials/another-guide/_info.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
title: Another Guide
author:
name: Jane Doe
url: https://example.com
avatar: https://avatars.githubusercontent.com/u/812331?v=4
authors:
- name: Jane Doe
url: https://example.com
avatar: https://avatars.githubusercontent.com/u/812331?v=4
- name: John Doe
url: https://example.com
avatar: https://avatars.githubusercontent.com/u/812331?v=4
github_repo: https://github.com/zkSync-Community-Hub
tags:
- web3
Expand Down
8 changes: 4 additions & 4 deletions content/tutorials/best-tutorial/_info.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
title: Best Tutorial
author:
name: Jane Doe
url: https://example.com
avatar: https://avatars.githubusercontent.com/u/812331?v=4
authors:
- name: Jane Doe
url: https://example.com
avatar: https://avatars.githubusercontent.com/u/812331?v=4
github_repo: https://github.com/zkSync-Community-Hub
tags:
- hardhat
Expand Down
8 changes: 4 additions & 4 deletions content/tutorials/cool-guide/_info.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
title: Cool Guide
author:
name: Jane Doe
url: https://example.com
avatar: https://avatars.githubusercontent.com/u/812331?v=4
authors:
- name: Jane Doe
url: https://example.com
avatar: https://avatars.githubusercontent.com/u/812331?v=4
github_repo: https://github.com/zkSync-Community-Hub
tags:
- foundry
Expand Down
8 changes: 4 additions & 4 deletions content/tutorials/example-guide/_info.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
title: Example Guide
author:
name: Jane Doe
url: https://example.com
avatar: https://avatars.githubusercontent.com/u/812331?v=4
authors:
- name: Jane Doe
url: https://example.com
avatar: https://avatars.githubusercontent.com/u/812331?v=4
github_repo: https://github.com/zkSync-Community-Hub
tags:
- account-abstraction
Expand Down
8 changes: 4 additions & 4 deletions content/tutorials/simple-tutorial/_info.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
title: Simple Tutorial
author:
name: Jane Doe
url: https://example.com
avatar: https://avatars.githubusercontent.com/u/812331?v=4
authors:
- name: Jane Doe
url: https://example.com
avatar: https://avatars.githubusercontent.com/u/812331?v=4
github_repo: https://github.com/zkSync-Community-Hub
tags:
- smart-contracts
Expand Down
12 changes: 4 additions & 8 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ useSeoMeta({

<p>{{ guide.summary }}</p>

<div class="my-4 flex w-auto items-center justify-normal">
<UAvatar
size="sm"
:src="guide.author.avatar"
:alt="guide.author.name"
/>
<span class="ml-3">{{ guide.author.name }}</span>
</div>
<AuthorsList
class="my-4"
:authors="guide.authors"
/>

<div class="mt-4">
<UBadge
Expand Down
21 changes: 6 additions & 15 deletions pages/tutorials/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ useSeoMeta({
description: info.value.summary,
ogDescription: info.value.summary,
ogType: 'article',
author: info.value.author.name,
author: info.value.authors[0].name,
});
const { data: navigation } = await useAsyncData(`${route.path}-sidenav`, () => {
Expand Down Expand Up @@ -113,6 +113,11 @@ const communityLinks = [
/>
<div class="grid grid-cols-8 gap-4 py-5">
<div class="col-span-5">
<AuthorsList
class="mb-4"
:authors="info.authors"
:with-links="true"
/>
<p>
{{ info.description }}
</p>
Expand All @@ -131,20 +136,6 @@ const communityLinks = [
</div>

<div class="col-span-3">
<div>
<a
:href="info.author.url"
target="_blank"
class="mb-4 flex w-auto items-center justify-normal hover:underline"
>
<UAvatar
size="md"
:src="info.author.avatar"
:alt="info.author.name"
/>
<span class="ml-3">{{ info.author.name }}</span>
</a>
</div>
<UButton
icon="i-simple-icons-github"
size="sm"
Expand Down

0 comments on commit 8553b42

Please sign in to comment.