Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/pages/brand-kit/github-badge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const readmeSnippetInput = {
useSeoMeta({
title: 'GitHub badge Β· Brand kit',
description: 'Add the skilld badge to a README. It links readers to the Skill or Repository page and shows no counts.',
robots: 'index,follow',
robots: 'noindex,follow',
})

useHead({
Expand Down
8 changes: 5 additions & 3 deletions layers/registry/app/pages/gh/[owner]/[repo]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ useHead(computed(() => ({
color="neutral"
variant="ghost"
/>
<BadgeEmbedControl v-bind="repositoryBadgeInput" />
<BadgeEmbedControl v-if="repoSource?.seoIndexable" v-bind="repositoryBadgeInput" />
</div>
</div>
</div>
Expand Down Expand Up @@ -698,9 +698,11 @@ useHead(computed(() => ({
</div>
</section>

<USeparator class="my-8" />
<template v-if="repoSource?.seoIndexable">
<USeparator class="my-8" />

<BadgeReadmeSnippet v-bind="repositoryBadgeInput" />
<BadgeReadmeSnippet v-bind="repositoryBadgeInput" />
</template>
</template>
</section>
</div>
Expand Down
12 changes: 12 additions & 0 deletions test/unit/github-badge-brand-kit.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { mountSuspended } from '@nuxt/test-utils/runtime'
import { describe, expect, it } from 'vitest'
import { nextTick } from 'vue'
import { injectHead, useNuxtApp } from '#imports'
import GithubBadgePage from '../../app/pages/brand-kit/github-badge.vue'

describe('github badge brand kit', () => {
Expand All @@ -15,4 +16,15 @@ describe('github badge brand kit', () => {

expect(wrapper.get('.github-readme').attributes('data-github-theme')).toBe('dark')
})

it('stays out of the index because it is a tool page, not a target', async () => {
await mountSuspended(GithubBadgePage)
const head = useNuxtApp().vueApp.runWithContext(() => injectHead())
const robots = [...head.entries.values()]
.flatMap(entry => (entry.input as { meta?: Array<{ name?: string, content?: string }> }).meta ?? [])
.filter(meta => meta.name === 'robots')
.map(meta => meta.content)

expect([...new Set(robots)]).toEqual(['noindex,follow'])
})
})
22 changes: 22 additions & 0 deletions test/unit/skill-badge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@ describe('skill badge', () => {
</a>`)
})

it('links a multi-skill repository badge to the repository hub, not its first skill', () => {
const input = {
owner: 'antfu',
repo: 'skills',
name: 'vite',
registryPath: '/gh/antfu/skills',
}

expect(skillBadgeImagePath(input)).toBe('/b/antfu/skills')
expect(skillBadgeEmbed(input)).toContain('<a href="https://skilld.dev/gh/antfu/skills">')
expect(skillBadgeEmbed(input)).toContain('<img alt="Skill repository on skilld.dev" src="https://skilld.dev/b/antfu/skills?theme=light">')
})

it('links a skill badge to the canonical skill URL', () => {
expect(skillBadgeEmbed({
owner: 'antfu',
repo: 'skills',
name: 'vite',
registryPath: '/gh/antfu/skills/vite',
})).toContain('<a href="https://skilld.dev/gh/antfu/skills/vite">')
})

it('keeps the skill name for a multi-skill repository', () => {
expect(skillBadgeEmbed({
owner: 'antfu',
Expand Down