@happydesigns/ui 0.16.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +70 -53
  2. package/app/app.config.ts +138 -165
  3. package/app/app.vue +0 -2
  4. package/app/assets/css/styles.css +38 -0
  5. package/app/components/Carousel.vue +33 -0
  6. package/app/components/{content/Snippet.vue → Snippet.vue} +6 -2
  7. package/app/components/article/ArticleGridDate.vue +19 -16
  8. package/app/components/article/ArticleHeaderBody.vue +26 -20
  9. package/app/components/article/ArticleHeadlineMeta.vue +37 -26
  10. package/app/components/article/ArticleList.vue +1 -1
  11. package/app/components/article/ArticlePage.vue +1 -1
  12. package/app/components/footer/FooterColumns.vue +60 -101
  13. package/app/components/search/ContentSearch.client.vue +59 -0
  14. package/app/components/studio/StudioLoginButton.client.vue +11 -3
  15. package/app/components/traits/Category.vue +1 -1
  16. package/app/components/traits/CopyButton.vue +40 -32
  17. package/app/components/traits/Links.vue +21 -17
  18. package/app/components/traits/Surround.vue +5 -6
  19. package/app/components/traits/Toc.vue +18 -16
  20. package/app/composables/useArticleList.ts +29 -27
  21. package/app/composables/useClipboard.ts +48 -26
  22. package/app/composables/useContentSearchData.ts +42 -0
  23. package/app/composables/useNavigationLinks.ts +40 -0
  24. package/app/composables/usePageContent.ts +1 -3
  25. package/app/composables/usePageSeo.ts +7 -15
  26. package/app/internal/pageLayout.ts +7 -0
  27. package/app/layouts/article.vue +137 -120
  28. package/app/layouts/content.vue +63 -59
  29. package/app/types/config.ts +91 -13
  30. package/app/utils/createContentSearchLoader.ts +45 -0
  31. package/app/utils/formatDate.ts +1 -1
  32. package/app/utils/formatDateTime.ts +1 -1
  33. package/app/utils/isNavigationTargetActive.ts +12 -0
  34. package/app/utils/resolveUsers.ts +56 -42
  35. package/nuxt.config.ts +1 -13
  36. package/package.json +35 -10
  37. package/schemas/collections.ts +4 -0
  38. package/schemas/indexes.ts +10 -0
  39. package/server/api/navigation.json.get.ts +11 -0
  40. package/server/api/search.json.get.ts +11 -0
  41. package/server/utils/contentSearch.ts +67 -0
  42. package/shared/types/app-config.d.ts +23 -0
  43. package/app/assets/css/main.css +0 -14
  44. package/app/components/content/Carousel.vue +0 -11
@@ -1,26 +1,37 @@
1
- <script setup lang="ts">
2
- import type { PageCollections } from '@nuxt/content'
3
-
4
- const props = defineProps<{
5
- page?: any
6
- collection?: keyof PageCollections
7
- }>()
8
-
9
- const { has } = useVariant(() => props.collection || 'article')
10
-
11
- const showCategory = computed(() => has('category').value && props.page?.category)
12
- const showDates = computed(() => has('dates').value && props.page?.date)
13
- const showLocation = computed(() => has('location').value && props.page?.location?.name)
14
- </script>
15
-
16
- <template>
17
- <div class="all:flex flex-wrap items-center gap-x-3 gap-y-2 text-muted">
18
- <HCategory v-if="showCategory" :category="page?.category" />
19
-
20
- <span v-if="showCategory && showDates" class="all:hidden sm:inline opacity-50">&middot;</span>
21
- <HDates v-if="showDates" :date="page?.date" :date-end="page?.dateEnd" />
22
-
23
- <span v-if="(showCategory || showDates) && showLocation" class="all:hidden sm:inline opacity-50">&middot;</span>
24
- <HLocation v-if="showLocation" :location="page?.location" />
25
- </div>
26
- </template>
1
+ <script setup lang="ts">
2
+ import type { PageCollections } from '@nuxt/content'
3
+
4
+ interface HeadlineMetaPage {
5
+ path?: string
6
+ category?: string
7
+ date?: string
8
+ dateEnd?: string
9
+ location?: {
10
+ name?: string
11
+ url?: string
12
+ }
13
+ }
14
+
15
+ const props = defineProps<{
16
+ page?: HeadlineMetaPage
17
+ collection?: keyof PageCollections
18
+ }>()
19
+
20
+ const { has } = useVariant(() => props.collection || 'article')
21
+
22
+ const showCategory = computed(() => has('category').value && Boolean(props.page?.category))
23
+ const showDates = computed(() => has('dates').value && Boolean(props.page?.date))
24
+ const showLocation = computed(() => has('location').value && Boolean(props.page?.location?.name))
25
+ </script>
26
+
27
+ <template>
28
+ <div class="all:flex flex-wrap items-center gap-x-3 gap-y-2 text-muted">
29
+ <HCategory v-if="showCategory" :category="page?.category" />
30
+
31
+ <span v-if="showCategory && showDates" class="all:hidden sm:inline opacity-50">&middot;</span>
32
+ <HDates v-if="showDates" :date="page?.date" :date-end="page?.dateEnd" />
33
+
34
+ <span v-if="(showCategory || showDates) && showLocation" class="all:hidden sm:inline opacity-50">&middot;</span>
35
+ <HLocation v-if="showLocation" :location="page?.location" />
36
+ </div>
37
+ </template>
@@ -56,7 +56,7 @@ const categories = computed(() => {
56
56
 
57
57
  <template>
58
58
  <div class="all:flex flex-col gap-8">
59
- <div v-if="!props.category" class="border-b border-gray-200 dark:border-gray-800">
59
+ <div v-if="!props.category" class="border-b border-default">
60
60
  <UNavigationMenu
61
61
  :items="categories"
62
62
  highlight
@@ -13,5 +13,5 @@ const { data: page } = await usePageContent({
13
13
  </script>
14
14
 
15
15
  <template>
16
- <ContentRenderer v-if="page" :value="page" />
16
+ <ContentRenderer v-if="page" :value="page" class="h-content" />
17
17
  </template>
@@ -1,101 +1,60 @@
1
- <script setup lang="ts" generic="T extends FooterColumnLink">
2
- import type { FooterColumn, FooterColumnLink, FooterColumnsProps, FooterColumnsSlots, SlotClass } from '@nuxt/ui'
3
- import { useAppConfig } from '#imports'
4
-
5
- interface HFooterColumnProps<T extends FooterColumnLink> extends /* @vue-ignore */ FooterColumnsProps<T> {
6
- lgCols?: number
7
- xlCols?: number
8
- }
9
-
10
- const props = defineProps<HFooterColumnProps<T>>()
11
- const slots = defineSlots<FooterColumnsSlots<T>>()
12
- const appConfig = useAppConfig()
13
-
14
- const footerColumns: FooterColumn<T>[] = props.columns
15
- ?? (appConfig?.app?.links?.footer as FooterColumn<T>[] | undefined)
16
- ?? []
17
-
18
- const leftCount = slots.left ? slots.left({}).length : 0
19
- const centerCount = footerColumns?.length ?? 0
20
- const rightCount = slots.right ? slots.right({}).length : 0
21
-
22
- const lgCount = Math.max(leftCount, centerCount, rightCount)
23
- const totalCount = leftCount + centerCount + rightCount
24
-
25
- function withLayoutClass(base: string, override?: SlotClass): SlotClass {
26
- if (typeof override === 'function')
27
- return defaults => [base, override(defaults)]
28
-
29
- return [base, override]
30
- }
31
-
32
- const ui = computed(() => ({
33
- ...props.ui,
34
- root: withLayoutClass('footer-cols-root all:grid grid-flow-row gap-y-12 gap-x-8', props.ui?.root),
35
- left: withLayoutClass('footer-cols-left', props.ui?.left),
36
- center: withLayoutClass('footer-cols-center', props.ui?.center),
37
- right: withLayoutClass('footer-cols-right', props.ui?.right),
38
- }))
39
- </script>
40
-
41
- <template>
42
- <UFooterColumns
43
- v-bind="props" :columns="footerColumns" :ui="ui"
44
- :style="{
45
- '--cols-sm': 1,
46
- '--cols-lg': props.lgCols ?? lgCount,
47
- '--cols-xl': props.xlCols ?? totalCount,
48
- '--span-left': leftCount,
49
- '--span-center': centerCount,
50
- '--span-right': rightCount,
51
- }"
52
- >
53
- <template v-if="leftCount > 0" #left>
54
- <slot name="left" />
55
- </template>
56
- <template v-if="rightCount > 0" #right>
57
- <slot name="right" />
58
- </template>
59
- </UFooterColumns>
60
- </template>
61
-
62
- <style>
63
- @import "tailwindcss" source("../..");
64
-
65
- .footer-cols-left {
66
- grid-column: span var(--span-left);
67
- }
68
-
69
- .footer-cols-center {
70
- grid-column: span var(--span-center);
71
- }
72
-
73
- .footer-cols-right {
74
- grid-column: span var(--span-right);
75
- }
76
-
77
- .footer-cols-left,
78
- .footer-cols-center,
79
- .footer-cols-right {
80
- display: contents;
81
- }
82
- .footer-cols-root {
83
- grid-template-columns: repeat(var(--cols-sm), minmax(0, 1fr));
84
- }
85
-
86
- @media (min-width: theme(--breakpoint-lg)) {
87
- .footer-cols-root {
88
- grid-template-columns: repeat(var(--cols-lg), minmax(0, 1fr));
89
- }
90
- }
91
-
92
- @media (min-width: theme(--breakpoint-xl)) {
93
- .footer-cols-root {
94
- grid-template-columns: repeat(var(--cols-xl), minmax(0, 1fr));
95
- }
96
- }
97
-
98
- .footer-cols-root p:last-child {
99
- margin-bottom: 0;
100
- }
101
- </style>
1
+ <script setup lang="ts" generic="T extends FooterColumnLink">
2
+ import type { FooterColumn, FooterColumnLink, FooterColumnsProps, FooterColumnsSlots, SlotClass } from '@nuxt/ui'
3
+ import { useAppConfig } from '#imports'
4
+
5
+ interface HFooterColumnProps<T extends FooterColumnLink> extends /* @vue-ignore */ FooterColumnsProps<T> {
6
+ /** Fixed column count from the lg breakpoint. Defaults to responsive auto-fit. */
7
+ lgCols?: number
8
+ /** Fixed column count from the xl breakpoint. Defaults to responsive auto-fit. */
9
+ xlCols?: number
10
+ }
11
+
12
+ const props = defineProps<HFooterColumnProps<T>>()
13
+ const slots = defineSlots<FooterColumnsSlots<T>>()
14
+ const appConfig = useAppConfig()
15
+
16
+ const footerColumns = computed<FooterColumn<T>[]>(() => (
17
+ props.columns
18
+ ?? (appConfig.app.links.footer as FooterColumn<T>[] | undefined)
19
+ ?? []
20
+ ))
21
+
22
+ const hasLeft = Boolean(slots.left)
23
+ const hasRight = Boolean(slots.right)
24
+
25
+ function withLayoutClass(base: string, override?: SlotClass): SlotClass {
26
+ if (typeof override === 'function')
27
+ return defaults => [base, override(defaults)]
28
+
29
+ return [base, override]
30
+ }
31
+
32
+ const ui = computed(() => ({
33
+ ...props.ui,
34
+ root: withLayoutClass('footer-cols-root all:grid grid-flow-row gap-y-12 gap-x-8', props.ui?.root),
35
+ left: withLayoutClass('footer-cols-left', props.ui?.left),
36
+ center: withLayoutClass('footer-cols-center', props.ui?.center),
37
+ right: withLayoutClass('footer-cols-right', props.ui?.right),
38
+ }))
39
+
40
+ const layoutStyle = computed(() => ({
41
+ ...(props.lgCols === undefined ? {} : { '--cols-lg': props.lgCols }),
42
+ ...(props.xlCols === undefined ? {} : { '--cols-xl': props.xlCols }),
43
+ }))
44
+ </script>
45
+
46
+ <template>
47
+ <UFooterColumns
48
+ v-bind="props"
49
+ :columns="footerColumns"
50
+ :ui="ui"
51
+ :style="layoutStyle"
52
+ >
53
+ <template v-if="hasLeft" #left>
54
+ <slot name="left" />
55
+ </template>
56
+ <template v-if="hasRight" #right>
57
+ <slot name="right" />
58
+ </template>
59
+ </UFooterColumns>
60
+ </template>
@@ -0,0 +1,59 @@
1
+ <script setup lang="ts">
2
+ import type { CommandPaletteGroup } from '@nuxt/ui'
3
+
4
+ const appConfig = useAppConfig()
5
+ const { open } = useContentSearch()
6
+ const search = computed(() => appConfig.app.search)
7
+ const searchTerm = ref('')
8
+ const { navigation, files, status, error, load } = useContentSearchData()
9
+
10
+ const groups = computed<CommandPaletteGroup[]>(() => {
11
+ const configuredGroups = search.value.groups ?? []
12
+
13
+ if (!error.value) {
14
+ return configuredGroups
15
+ }
16
+
17
+ return [
18
+ {
19
+ id: 'search-error',
20
+ label: search.value.error?.title,
21
+ ignoreFilter: true,
22
+ items: [
23
+ {
24
+ label: search.value.error?.retryLabel,
25
+ description: search.value.error?.description,
26
+ icon: 'i-lucide-refresh-cw',
27
+ onSelect: () => void load(),
28
+ },
29
+ ],
30
+ },
31
+ ...configuredGroups,
32
+ ]
33
+ })
34
+
35
+ watch(open, (isOpen) => {
36
+ if (isOpen) {
37
+ void load().then(() => {
38
+ if (error.value) {
39
+ console.error('Failed to load the search index.', error.value)
40
+ }
41
+ })
42
+ }
43
+ }, { immediate: true })
44
+ </script>
45
+
46
+ <template>
47
+ <UContentSearch
48
+ v-model:search-term="searchTerm"
49
+ :title="search.title"
50
+ :description="search.description"
51
+ :placeholder="search.placeholder"
52
+ :links="search.links"
53
+ :groups="groups"
54
+ :files="files"
55
+ :navigation="navigation"
56
+ :loading="status === 'pending'"
57
+ :fuse="{ resultLimit: search.resultLimit }"
58
+ />
59
+ </template>
@@ -13,15 +13,23 @@ withDefaults(defineProps<{
13
13
  icon: 'i-lucide-log-in',
14
14
  })
15
15
 
16
- interface StudioSession {
17
- user?: StudioUser | null
16
+ interface StudioSession {
17
+ user?: StudioUser | null
18
+ }
19
+
20
+ interface StudioRuntimeConfig {
21
+ dev?: boolean
22
+ route?: string
18
23
  }
19
24
 
20
25
  const runtimeConfig = useRuntimeConfig()
21
26
  const sessionCheckCookie = useCookie<string | null>('studio-session-check')
22
27
  const sessionUser = ref<StudioUser | null | undefined>()
23
28
 
24
- const studio = computed(() => runtimeConfig.public.studio)
29
+ const studio = computed<StudioRuntimeConfig>(() => {
30
+ const config = runtimeConfig.public.studio
31
+ return config && typeof config === 'object' ? config as StudioRuntimeConfig : {}
32
+ })
25
33
  const studioRoute = computed(() => studio.value.route || '/_studio')
26
34
 
27
35
  onMounted(async () => {
@@ -5,5 +5,5 @@ defineProps<{
5
5
  </script>
6
6
 
7
7
  <template>
8
- <span class="text-primary-500 dark:text-primary-400 font-medium">{{ category }}</span>
8
+ <span class="font-medium text-primary">{{ category }}</span>
9
9
  </template>
@@ -1,32 +1,40 @@
1
- <script setup lang="ts">
2
- const props = defineProps<{
3
- path?: string
4
- icon?: string
5
- label?: string
6
- successIcon?: string
7
- successLabel?: string
8
- }>()
9
-
10
- const { copy } = useClipboard()
11
- const url = useRequestURL()
12
- const route = useRoute()
13
-
14
- function copyLink() {
15
- copy(`${url.origin}${props.path ?? route.path}`, {
16
- id: 'article-copy-link',
17
- title: props.successLabel,
18
- icon: props.successIcon,
19
- })
20
- }
21
- </script>
22
-
23
- <template>
24
- <UButton
25
- :icon="icon"
26
- variant="ghost"
27
- color="neutral"
28
- @click="copyLink"
29
- >
30
- {{ label }}
31
- </UButton>
32
- </template>
1
+ <script setup lang="ts">
2
+ const props = defineProps<{
3
+ path?: string
4
+ icon?: string
5
+ label?: string
6
+ successIcon?: string
7
+ successLabel?: string
8
+ errorIcon?: string
9
+ errorLabel?: string
10
+ }>()
11
+
12
+ const { copy } = useClipboard()
13
+ const url = useRequestURL()
14
+ const route = useRoute()
15
+
16
+ async function copyLink() {
17
+ await copy(`${url.origin}${props.path ?? route.path}`, {
18
+ id: 'article-copy-link',
19
+ title: props.successLabel,
20
+ icon: props.successIcon,
21
+ error: {
22
+ id: 'article-copy-link-error',
23
+ title: props.errorLabel,
24
+ icon: props.errorIcon,
25
+ color: 'error',
26
+ },
27
+ })
28
+ }
29
+ </script>
30
+
31
+ <template>
32
+ <UButton
33
+ :icon="icon"
34
+ variant="ghost"
35
+ color="neutral"
36
+ @click="copyLink"
37
+ >
38
+ {{ label }}
39
+ </UButton>
40
+ </template>
@@ -1,17 +1,21 @@
1
- <script setup lang="ts">
2
- import type { ButtonProps } from '@nuxt/ui'
3
-
4
- defineProps<{
5
- links?: ButtonProps[]
6
- }>()
7
- </script>
8
-
9
- <template>
10
- <UButton
11
- v-for="(link, index) in links"
12
- :key="index"
13
- variant="subtle"
14
- size="sm"
15
- v-bind="link"
16
- />
17
- </template>
1
+ <script setup lang="ts">
2
+ import type { PageCollections } from '@nuxt/content'
3
+ import type { ButtonProps } from '@nuxt/ui'
4
+
5
+ const props = defineProps<{
6
+ links?: PageCollections['event']['links']
7
+ }>()
8
+
9
+ // Nuxt Content preserves the inherited schema shape but widens a few DOM props to unknown.
10
+ const buttonLinks = computed(() => props.links as ButtonProps[] | undefined)
11
+ </script>
12
+
13
+ <template>
14
+ <UButton
15
+ v-for="(link, index) in buttonLinks"
16
+ :key="index"
17
+ variant="subtle"
18
+ size="sm"
19
+ v-bind="link"
20
+ />
21
+ </template>
@@ -11,28 +11,27 @@ const props = defineProps<{
11
11
  }>()
12
12
 
13
13
  const route = useRoute()
14
- const collection = computed(() => props.collection || 'article')
14
+ const collection = computed(() => props.collection)
15
15
  const path = computed(() => route.path)
16
16
  const key = computed(() => `surround-${String(collection.value)}-${path.value}`)
17
17
 
18
18
  const { data: surround } = await useAsyncData(
19
19
  key,
20
20
  () => {
21
- const colName = collection.value as any
22
21
  const qc = props.query || {}
23
22
 
24
- const fields = (qc.fields || ['title', 'description', 'published']) as any
23
+ const fields = (qc.fields || ['title', 'description', 'published']) as Array<keyof PageCollections[C]>
25
24
  const order = qc.order
26
25
  const where = qc.where || [{ field: 'published', operator: '=', value: true }]
27
26
 
28
- let query = queryCollectionItemSurroundings(colName, path.value, { fields })
27
+ let query = queryCollectionItemSurroundings(collection.value, path.value, { fields })
29
28
 
30
29
  where.forEach((filter) => {
31
- query = query.where(filter.field as any, filter.operator as any, filter.value)
30
+ query = query.where(filter.field, filter.operator, filter.value)
32
31
  })
33
32
 
34
33
  if (order) {
35
- query = query.order(order.field as any, order.direction)
34
+ query = query.order(order.field as keyof PageCollections[C], order.direction)
36
35
  }
37
36
 
38
37
  return query
@@ -1,16 +1,18 @@
1
- <script setup lang="ts">
2
- defineProps<{
3
- links?: any[]
4
- title?: string
5
- }>()
6
-
7
- const appConfig = useAppConfig()
8
- </script>
9
-
10
- <template>
11
- <UContentToc
12
- v-if="links?.length"
13
- :links="links"
14
- :title="title || appConfig.app.toc?.title"
15
- />
16
- </template>
1
+ <script setup lang="ts">
2
+ import type { ContentTocLink } from '@nuxt/ui'
3
+
4
+ defineProps<{
5
+ links?: ContentTocLink[]
6
+ title?: string
7
+ }>()
8
+
9
+ const appConfig = useAppConfig()
10
+ </script>
11
+
12
+ <template>
13
+ <UContentToc
14
+ v-if="links?.length"
15
+ :links="links"
16
+ :title="title || appConfig.app.toc?.title"
17
+ />
18
+ </template>
@@ -6,7 +6,7 @@ import { computed, toValue } from 'vue'
6
6
  export interface ArticleFilter {
7
7
  field: string
8
8
  operator: SQLOperator
9
- value?: any
9
+ value?: unknown
10
10
  }
11
11
 
12
12
  export interface UseArticleListOptions<C extends keyof PageCollections = 'article'> {
@@ -63,13 +63,10 @@ export function useArticleList<C extends keyof PageCollections = 'article'>(opti
63
63
  const queryKey = computed(() => `${String(collection.value)}-list-${page.value}-${itemsPerPage.value}-${category.value || 'all'}-${labelAll.value}-${JSON.stringify(where.value)}-${JSON.stringify(sort.value)}-${publishedOnly.value}`)
64
64
 
65
65
  return useAsyncData(queryKey, async () => {
66
- // We cast the query to a version that includes the standard article fields
67
- // This avoids 'any' while still allowing the query to work with generic collections
66
+ // The result keeps consumer collection fields together with the article fields used by the UI.
68
67
  type ArticleItem = Collections[C] & Collections['article']
69
- type ArticleQueryBuilder = ReturnType<typeof queryCollection<'article'>>
70
-
71
68
  const getDataQuery = () => {
72
- let query = queryCollection(collection.value) as unknown as ArticleQueryBuilder
69
+ let query = queryCollection(collection.value)
73
70
 
74
71
  if (publishedOnly.value) {
75
72
  query = query.where('published', '=', true)
@@ -82,7 +79,7 @@ export function useArticleList<C extends keyof PageCollections = 'article'>(opti
82
79
  // Apply additional filters
83
80
  if (where.value && Array.isArray(where.value)) {
84
81
  where.value.forEach((filter) => {
85
- query = query.where(filter.field as any, filter.operator, filter.value)
82
+ query = query.where(filter.field, filter.operator, filter.value)
86
83
  })
87
84
  }
88
85
  return query
@@ -91,16 +88,25 @@ export function useArticleList<C extends keyof PageCollections = 'article'>(opti
91
88
  let finalQuery = getDataQuery()
92
89
 
93
90
  if (sort.value) {
94
- finalQuery = finalQuery.order(sort.value.field as any, sort.value.direction)
91
+ finalQuery = finalQuery.order(sort.value.field as keyof Collections[C], sort.value.direction)
95
92
  }
96
93
 
97
- const articles = await finalQuery
98
- .skip((page.value - 1) * itemsPerPage.value)
99
- .limit(itemsPerPage.value)
100
- .all() as ArticleItem[]
101
-
102
- // Resolve details for each article
103
- const resolved = await Promise.all(articles.map(async (article) => {
94
+ const [articles, total] = await Promise.all([
95
+ finalQuery
96
+ .skip((page.value - 1) * itemsPerPage.value)
97
+ .limit(itemsPerPage.value)
98
+ .all() as Promise<ArticleItem[]>,
99
+ getDataQuery().count() as Promise<number>,
100
+ ])
101
+
102
+ const userProps = config.value.user ?? {}
103
+ const authorsByUsername = await resolveUserMap(
104
+ articles.flatMap(article => article.authors ?? []),
105
+ userProps,
106
+ )
107
+
108
+ // Resolve display details without issuing additional collection queries.
109
+ const resolved = articles.map((article) => {
104
110
  // Resolve Category Badge directly
105
111
  const categoryKey = article.category
106
112
  let resolvedBadge: BadgeProps | undefined
@@ -112,23 +118,19 @@ export function useArticleList<C extends keyof PageCollections = 'article'>(opti
112
118
  }
113
119
  }
114
120
 
115
- // Resolve Authors
116
- let resolvedAuthors: Awaited<ReturnType<typeof resolveUsers>> = []
117
- if (article.authors?.length) {
118
- const userProps = config.value.user ?? {}
119
- resolvedAuthors = await resolveUsers(article.authors, userProps)
120
- }
121
-
121
+ // Preserve the author order declared in front matter.
122
+ const resolvedAuthors = (article.authors ?? []).flatMap((username) => {
123
+ const author = authorsByUsername.get(username)
124
+ return author ? [author] : []
125
+ })
126
+
122
127
  return {
123
128
  ...article,
124
129
  resolvedBadge,
125
130
  resolvedAuthors,
126
131
  }
127
- }))
128
-
129
- // Total count for pagination
130
- const total = await getDataQuery().count() as number
131
-
132
+ })
133
+
132
134
  return {
133
135
  articles: resolved,
134
136
  total,