-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Surface template and collection in search results and on asset page a…
…ccording to settings (#273)
- Loading branch information
Showing
8 changed files
with
164 additions
and
8 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
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,53 @@ | ||
<template> | ||
<Tuple v-if="collectionPath?.length" label="Collection"> | ||
<template | ||
v-for="(collection, index) in collectionPath" | ||
:key="collection.id"> | ||
<Link | ||
:to="`/collections/${collection.id}`" | ||
:class="{ 'mr-1': index < collectionPath.length - 1 }"> | ||
{{ collection.title }} | ||
</Link> | ||
<span v-if="index < collectionPath.length - 1" class="mr-1">/</span> | ||
</template> | ||
</Tuple> | ||
</template> | ||
<script setup lang="ts"> | ||
import Tuple from "@/components/Tuple/Tuple.vue"; | ||
import Link from "@/components/Link/Link.vue"; | ||
import { computed } from "vue"; | ||
import { useInstanceStore } from "@/stores/instanceStore"; | ||
import { AssetCollection } from "@/types"; | ||
const props = defineProps<{ | ||
collectionId: AssetCollection["id"]; | ||
}>(); | ||
const instanceStore = useInstanceStore(); | ||
// create a path to the collection | ||
// so we can display it as a breadcrumb | ||
// like "Collection A / Collection B / Collection C" | ||
const collectionPath = computed(() => { | ||
if (!props.collectionId) return null; | ||
const collection = instanceStore.collectionIndex[props.collectionId]; | ||
if (!collection) { | ||
throw new Error( | ||
`Collection ${props.collectionId} not found in instanceStore` | ||
); | ||
} | ||
// construct a path to this collection | ||
const path = [collection]; | ||
let child = collection; | ||
while (child.parentId) { | ||
child = instanceStore.collectionIndex[child.parentId]; | ||
path.unshift(child); | ||
} | ||
return path; | ||
}); | ||
</script> | ||
<style scoped></style> |
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,21 @@ | ||
<template> | ||
<div v-if="collectionHierarchy?.length"> | ||
<dt class="font-bold text-xs uppercase">Collection</dt> | ||
<dd> | ||
<span | ||
v-for="collection in collectionHierarchy" | ||
:key="collection.id" | ||
class="after:content-['/'] after:mr-1 after:ml-1 after:text-neutral-400 after:last:content-none"> | ||
{{ collection.title }} | ||
</span> | ||
</dd> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import * as T from "@/types"; | ||
defineProps<{ | ||
collectionHierarchy: T.SearchResultMatch["collectionHierarchy"]; | ||
}>(); | ||
</script> | ||
<style scoped></style> |
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