@happydesigns/ui 0.13.5
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.
- package/README.md +94 -0
- package/app/app.config.ts +169 -0
- package/app/assets/css/main.css +14 -0
- package/app/components/article/ArticleGrid.vue +158 -0
- package/app/components/article/ArticleGridDate.vue +16 -0
- package/app/components/article/ArticleHeaderBody.vue +20 -0
- package/app/components/article/ArticleHeadlineMeta.vue +26 -0
- package/app/components/article/ArticleList.vue +95 -0
- package/app/components/article/ArticlePage.vue +16 -0
- package/app/components/content/Carousel.vue +11 -0
- package/app/components/content/Snippet.vue +31 -0
- package/app/components/footer/FooterButtons.vue +13 -0
- package/app/components/footer/FooterColumnHeading.vue +5 -0
- package/app/components/footer/FooterColumns.vue +105 -0
- package/app/components/footer/FooterCopyright.vue +29 -0
- package/app/components/traits/Authors.vue +20 -0
- package/app/components/traits/BackButton.vue +26 -0
- package/app/components/traits/Category.vue +9 -0
- package/app/components/traits/CopyButton.vue +39 -0
- package/app/components/traits/Dates.vue +20 -0
- package/app/components/traits/Links.vue +17 -0
- package/app/components/traits/Location.vue +20 -0
- package/app/components/traits/Separator.vue +26 -0
- package/app/components/traits/SeparatorButtons.vue +56 -0
- package/app/components/traits/Surround.vue +60 -0
- package/app/components/traits/Toc.vue +16 -0
- package/app/composables/useArticleList.ts +156 -0
- package/app/composables/useCategoryBadge.ts +27 -0
- package/app/composables/useClipboard.ts +26 -0
- package/app/composables/usePageContent.ts +31 -0
- package/app/composables/usePageSeo.ts +30 -0
- package/app/layouts/article.vue +128 -0
- package/app/layouts/content.vue +67 -0
- package/app/layouts/default.vue +12 -0
- package/app/types/config.ts +6 -0
- package/app/utils/formatDate.ts +26 -0
- package/app/utils/formatDateTime.ts +28 -0
- package/app/utils/resolvePageHeader.ts +16 -0
- package/app/utils/resolveUsers.ts +16 -0
- package/content.config.ts +6 -0
- package/nuxt.config.ts +80 -0
- package/package.json +60 -0
- package/schemas/collections.ts +46 -0
- package/schemas/index.ts +2 -0
- package/schemas/traits.ts +90 -0
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# @happydesigns/ui
|
|
2
|
+
|
|
3
|
+
A foundational **Nuxt Layer** providing a consistent UI and content structure for Nuxt applications. Built with Nuxt 4, Nuxt UI 4, and Nuxt Content 3.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎨 **Nuxt UI v4 Integration**: Pre-configured with Tailwind and a set of reusable components.
|
|
8
|
+
- 📝 **Nuxt Content v3 Ready**: Provides pre-defined collections for pages and snippets to jumpstart content-driven sites.
|
|
9
|
+
- 🔌 **Extendable**: Designed as a Nuxt Layer that can be easily extended and customized by consuming projects.
|
|
10
|
+
- 🧱 **Prefixed Components**: Layer components are automatically prefixed with `H` (e.g., `<HFooterButtons />`) to avoid naming collisions.
|
|
11
|
+
- ✨ **Studio Ready**: Integrated with [Nuxt Studio](https://nuxt.studio/) for a seamless content editing experience.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Install the package in your Nuxt project:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @happydesigns/ui
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Add the layer to your `nuxt.config.ts`:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
export default defineNuxtConfig({
|
|
25
|
+
extends: ['@happydesigns/ui']
|
|
26
|
+
})
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Configuration
|
|
30
|
+
|
|
31
|
+
This layer provides a type-safe configuration via `app.config.ts`. You can override these values in your project's own `app.config.ts`:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
export default defineAppConfig({
|
|
35
|
+
app: {
|
|
36
|
+
meta: {
|
|
37
|
+
copyright: {
|
|
38
|
+
copyrightYear: 2026,
|
|
39
|
+
copyrightHolder: 'happydesigns',
|
|
40
|
+
copyrightHomepage: 'https://happydesigns.de'
|
|
41
|
+
},
|
|
42
|
+
socials: [
|
|
43
|
+
{ icon: 'i-simple-icons-github', to: 'https://github.com/happydesigns', target: '_blank' }
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
links: {
|
|
47
|
+
footer: [
|
|
48
|
+
{ label: 'Privacy Policy', to: '/privacy' },
|
|
49
|
+
{ label: 'Terms of Service', to: '/terms' }
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Content Configuration
|
|
57
|
+
|
|
58
|
+
By default, this layer provides a `content.config.ts` that defines two collections: `page` (sourced from `pages/`) and `snippet` (sourced from `snippets/`).
|
|
59
|
+
|
|
60
|
+
You can use these as-is by following the default directory structure, or you can define your own `content.config.ts` in your main application to extend or completely override these collections:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
// your-app/content.config.ts
|
|
64
|
+
import { pageCollectionConfig, snippetCollectionConfig } from '@happydesigns/ui/content.config'
|
|
65
|
+
import { defineContentConfig } from '@nuxt/content'
|
|
66
|
+
|
|
67
|
+
export default defineContentConfig({
|
|
68
|
+
collections: {
|
|
69
|
+
// Reuse the layer's configs
|
|
70
|
+
page: pageCollectionConfig,
|
|
71
|
+
snippet: snippetCollectionConfig,
|
|
72
|
+
// Or add your own
|
|
73
|
+
posts: defineCollection({ })
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Development
|
|
79
|
+
|
|
80
|
+
If you want to contribute to the layer or run it locally:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Install dependencies
|
|
84
|
+
pnpm install
|
|
85
|
+
|
|
86
|
+
# Prepare types
|
|
87
|
+
pnpm prepare
|
|
88
|
+
|
|
89
|
+
# Start the playground (dev server)
|
|
90
|
+
pnpm dev
|
|
91
|
+
|
|
92
|
+
# Build the playground
|
|
93
|
+
pnpm build
|
|
94
|
+
```
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { ButtonProps, FooterColumn } from '@nuxt/ui'
|
|
2
|
+
|
|
3
|
+
export * from './types/config'
|
|
4
|
+
|
|
5
|
+
export default defineAppConfig({
|
|
6
|
+
variants: {
|
|
7
|
+
// UI feature variants — config overrides (extends defined in nuxt.config.ts)
|
|
8
|
+
user: { config: { user: { target: '_blank' } } },
|
|
9
|
+
backButton: { config: { backButton: { icon: 'i-ph-arrow-left', label: 'Back' } as Pick<ButtonProps, 'icon' | 'label' | 'to'> } },
|
|
10
|
+
dates: { config: { helloThere: 'general kenobi' } },
|
|
11
|
+
copyButton: {
|
|
12
|
+
config: {
|
|
13
|
+
copyButton: {
|
|
14
|
+
icon: 'i-ph-link-simple-duotone',
|
|
15
|
+
label: 'Copy URL',
|
|
16
|
+
successIcon: 'i-lucide-copy-check',
|
|
17
|
+
successLabel: 'Link copied to clipboard',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
separator: { config: { separator: { buttons: [], separator: 'or' } } },
|
|
22
|
+
surround: {
|
|
23
|
+
config: {
|
|
24
|
+
surround: {
|
|
25
|
+
show: true,
|
|
26
|
+
prevIcon: 'i-lucide-arrow-left',
|
|
27
|
+
nextIcon: 'i-lucide-arrow-right',
|
|
28
|
+
prevLabel: 'Previous',
|
|
29
|
+
nextLabel: 'Next',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
// Collection variants — runtime config overrides only
|
|
35
|
+
article: {
|
|
36
|
+
config: {
|
|
37
|
+
youShallNot: 'pass',
|
|
38
|
+
query: {
|
|
39
|
+
fields: ['title', 'description', 'status', 'date'],
|
|
40
|
+
order: { field: 'date', direction: 'DESC' },
|
|
41
|
+
where: [{ field: 'status', operator: '=', value: 'published' }],
|
|
42
|
+
},
|
|
43
|
+
categories: {},
|
|
44
|
+
breadcrumbs: [],
|
|
45
|
+
list: {
|
|
46
|
+
itemsPerPage: 12,
|
|
47
|
+
labelAll: 'All',
|
|
48
|
+
noResultsMessage: 'No articles found.',
|
|
49
|
+
noResultsIcon: 'i-ph-article-ny-times-light',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
event: {
|
|
54
|
+
config: {
|
|
55
|
+
query: {
|
|
56
|
+
fields: ['title', 'description', 'status', 'date', 'dateEnd', 'location'],
|
|
57
|
+
order: { field: 'date', direction: 'DESC' },
|
|
58
|
+
where: [{ field: 'status', operator: '=', value: 'published' }],
|
|
59
|
+
},
|
|
60
|
+
categories: {},
|
|
61
|
+
breadcrumbs: [],
|
|
62
|
+
list: {
|
|
63
|
+
itemsPerPage: 12,
|
|
64
|
+
labelAll: 'All',
|
|
65
|
+
noResultsMessage: 'No events found.',
|
|
66
|
+
noResultsIcon: 'i-ph-calendar-blank',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
app: {
|
|
73
|
+
meta: {
|
|
74
|
+
copyright: {},
|
|
75
|
+
socials: [],
|
|
76
|
+
github: {
|
|
77
|
+
repo: '',
|
|
78
|
+
branch: 'main',
|
|
79
|
+
dir: 'content',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
links: {
|
|
84
|
+
header: [],
|
|
85
|
+
footer: [],
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
icons: {} as Record<string, string>,
|
|
89
|
+
|
|
90
|
+
toc: {
|
|
91
|
+
title: '',
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
date: {
|
|
95
|
+
locale: 'en',
|
|
96
|
+
options: {
|
|
97
|
+
year: 'numeric',
|
|
98
|
+
month: 'short',
|
|
99
|
+
day: 'numeric',
|
|
100
|
+
} as Intl.DateTimeFormatOptions,
|
|
101
|
+
datetimeOptions: {
|
|
102
|
+
year: 'numeric',
|
|
103
|
+
month: 'short',
|
|
104
|
+
day: 'numeric',
|
|
105
|
+
hour: 'numeric',
|
|
106
|
+
minute: 'numeric',
|
|
107
|
+
} as Intl.DateTimeFormatOptions,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
ui: {
|
|
112
|
+
main: {
|
|
113
|
+
base: 'wrap-break-word',
|
|
114
|
+
},
|
|
115
|
+
footerColumns: {
|
|
116
|
+
slots: {},
|
|
117
|
+
columns: {},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
declare module '@nuxt/schema' {
|
|
123
|
+
interface AppConfigInput {
|
|
124
|
+
app?: {
|
|
125
|
+
[key: string]: any
|
|
126
|
+
meta?: {
|
|
127
|
+
copyright?: {
|
|
128
|
+
/** The year in which the copyright was issued */
|
|
129
|
+
copyrightYear?: number
|
|
130
|
+
/** The name of the copyright holder */
|
|
131
|
+
copyrightHolder?: string
|
|
132
|
+
/** The homepage URL of the copyright holder */
|
|
133
|
+
copyrightHomepage?: string
|
|
134
|
+
}
|
|
135
|
+
/** Social button definitions (e.g. Instagram, Facebook, GitHub) */
|
|
136
|
+
socials?: Array<ButtonProps>
|
|
137
|
+
/** Configuration for GitHub repository info */
|
|
138
|
+
github?: {
|
|
139
|
+
/** The repository identifier (e.g. 'sfbiberach/schachfreunde-biberach.de') */
|
|
140
|
+
repo?: string
|
|
141
|
+
/** The branch name (e.g. 'main') */
|
|
142
|
+
branch?: string
|
|
143
|
+
/** The directory where the content is stored (e.g. 'content') */
|
|
144
|
+
dir?: string
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** Link collections for various UI regions (e.g. header, footer) */
|
|
148
|
+
links?: {
|
|
149
|
+
header?: Array<FooterColumn>
|
|
150
|
+
footer?: Array<FooterColumn>
|
|
151
|
+
}
|
|
152
|
+
/** Configuration for the table of contents */
|
|
153
|
+
toc?: {
|
|
154
|
+
/** The default title to be shown in the table of contents */
|
|
155
|
+
title?: string
|
|
156
|
+
}
|
|
157
|
+
/** A mapping of internal identifier strings to icon strings */
|
|
158
|
+
icons?: Record<string, string>
|
|
159
|
+
date?: {
|
|
160
|
+
/** The locale used for date formatting (e.g. 'en', 'de') */
|
|
161
|
+
locale?: string
|
|
162
|
+
/** Options for Intl.DateTimeFormat for dates */
|
|
163
|
+
options?: Intl.DateTimeFormatOptions
|
|
164
|
+
/** Options for Intl.DateTimeFormat for datetimes */
|
|
165
|
+
datetimeOptions?: Intl.DateTimeFormatOptions
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
@import "@nuxt/ui";
|
|
3
|
+
|
|
4
|
+
@custom-variant all (&);
|
|
5
|
+
|
|
6
|
+
@layer theme {
|
|
7
|
+
p .iconify {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
margin-right: --spacing(1);
|
|
10
|
+
width: 1em !important;
|
|
11
|
+
height: 1em !important;
|
|
12
|
+
transform: translateY(-1px);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<script setup lang="ts" generic="C extends keyof PageCollections = 'article'">
|
|
2
|
+
import type { PageCollections } from '@nuxt/content'
|
|
3
|
+
import type { ArticleFilter } from '~/composables/useArticleList'
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(defineProps<{
|
|
6
|
+
/** Optional fixed category to filter by */
|
|
7
|
+
category?: string
|
|
8
|
+
/** The orientation of the blog posts list */
|
|
9
|
+
orientation?: 'horizontal' | 'vertical'
|
|
10
|
+
/** The collection to fetch articles from */
|
|
11
|
+
collection?: C
|
|
12
|
+
/** Additional custom filters */
|
|
13
|
+
where?: ArticleFilter[]
|
|
14
|
+
/** Field to sort by. Set to false to disable default sorting. */
|
|
15
|
+
sort?: { field: string, direction: 'ASC' | 'DESC' } | false
|
|
16
|
+
/** Status to filter by. Set to false to disable default status filtering. */
|
|
17
|
+
status?: string | false
|
|
18
|
+
/** Optional items per page override */
|
|
19
|
+
itemsPerPage?: number
|
|
20
|
+
}>(), {
|
|
21
|
+
sort: undefined,
|
|
22
|
+
status: undefined,
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const route = useRoute()
|
|
26
|
+
|
|
27
|
+
/** Resolve the configuration for this collection using the smart merger */
|
|
28
|
+
const { config: collectionConfig } = useVariant(() => props.collection || 'article')
|
|
29
|
+
|
|
30
|
+
const itemsPerPage = computed(() => props.itemsPerPage || collectionConfig.value.list?.itemsPerPage || 12)
|
|
31
|
+
const labelAll = computed(() => collectionConfig.value.list?.labelAll || 'All')
|
|
32
|
+
const noResultsMessage = computed(() => collectionConfig.value.list?.noResultsMessage || 'No items found.')
|
|
33
|
+
const noResultsIcon = computed(() => collectionConfig.value.list?.noResultsIcon)
|
|
34
|
+
|
|
35
|
+
const page = ref(Number(route.query.page) || 1)
|
|
36
|
+
const selectedCategory = ref(props.category || (route.query.category as string) || String(labelAll.value))
|
|
37
|
+
const resolvedOrientation = computed(() => props.orientation || 'horizontal')
|
|
38
|
+
|
|
39
|
+
// Update internal state when props change (from ArticleList or parent)
|
|
40
|
+
watch(() => props.category, (newCategory) => {
|
|
41
|
+
if (newCategory) {
|
|
42
|
+
selectedCategory.value = newCategory
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Fetch articles using the composable
|
|
47
|
+
const { data, status: fetchStatus } = await useArticleList({
|
|
48
|
+
page,
|
|
49
|
+
itemsPerPage,
|
|
50
|
+
category: selectedCategory,
|
|
51
|
+
labelAll,
|
|
52
|
+
collection: () => props.collection || 'article' as C,
|
|
53
|
+
where: () => props.where,
|
|
54
|
+
sort: () => props.sort,
|
|
55
|
+
status: () => props.status,
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
// Watchers and lifecycle
|
|
59
|
+
function updateQuery() {
|
|
60
|
+
const query: Record<string, any> = { ...route.query }
|
|
61
|
+
if (page.value > 1)
|
|
62
|
+
query.page = page.value
|
|
63
|
+
else
|
|
64
|
+
delete query.page
|
|
65
|
+
|
|
66
|
+
// Only update category in query if we are not in a fixed category mode
|
|
67
|
+
if (!props.category) {
|
|
68
|
+
if (selectedCategory.value !== labelAll.value)
|
|
69
|
+
query.category = selectedCategory.value
|
|
70
|
+
else
|
|
71
|
+
delete query.category
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
navigateTo({ query })
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
watch(page, () => {
|
|
78
|
+
updateQuery()
|
|
79
|
+
if (import.meta.client) {
|
|
80
|
+
window.scrollTo({ top: 0, behavior: 'smooth' })
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
// Sync state with query on back/forward navigation
|
|
85
|
+
watch(() => route.query, (newQuery) => {
|
|
86
|
+
page.value = Number(newQuery.page) || 1
|
|
87
|
+
if (!props.category) {
|
|
88
|
+
selectedCategory.value = (newQuery.category as string) || labelAll.value
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
// Delayed loader to avoid flickering on fast navigations
|
|
93
|
+
const showLoader = ref(false)
|
|
94
|
+
let loaderTimeout: any = null
|
|
95
|
+
|
|
96
|
+
watch(fetchStatus, (newStatus) => {
|
|
97
|
+
if (newStatus === 'pending') {
|
|
98
|
+
loaderTimeout = setTimeout(() => {
|
|
99
|
+
showLoader.value = true
|
|
100
|
+
}, 200)
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
clearTimeout(loaderTimeout)
|
|
104
|
+
showLoader.value = false
|
|
105
|
+
}
|
|
106
|
+
}, { immediate: true })
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<template>
|
|
110
|
+
<div class="all:flex flex-col gap-8">
|
|
111
|
+
<div v-if="showLoader && !data?.articles.length" class="all:flex justify-center py-20">
|
|
112
|
+
<UIcon name="i-lucide-loader-circle" class="size-12 animate-spin text-muted" />
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<UBlogPosts
|
|
116
|
+
v-else-if="data?.articles.length"
|
|
117
|
+
:orientation="resolvedOrientation"
|
|
118
|
+
:ui="{
|
|
119
|
+
base: resolvedOrientation === 'horizontal' ? 'sm:grid sm:grid-cols-2 lg:grid-cols-3' : '',
|
|
120
|
+
}"
|
|
121
|
+
:class="{ 'opacity-50 transition-opacity': fetchStatus === 'pending' }"
|
|
122
|
+
>
|
|
123
|
+
<UBlogPost
|
|
124
|
+
v-for="article in data.articles"
|
|
125
|
+
:key="article.path"
|
|
126
|
+
:to="article.path"
|
|
127
|
+
:title="article.title"
|
|
128
|
+
:description="article.description"
|
|
129
|
+
:badge="article.resolvedBadge"
|
|
130
|
+
:authors="article.resolvedAuthors"
|
|
131
|
+
variant="subtle"
|
|
132
|
+
:ui="{
|
|
133
|
+
title: 'line-clamp-2',
|
|
134
|
+
description: 'line-clamp-3',
|
|
135
|
+
}"
|
|
136
|
+
>
|
|
137
|
+
<template #date>
|
|
138
|
+
<slot name="date" :article="article">
|
|
139
|
+
<HArticleGridDate :article="article" />
|
|
140
|
+
</slot>
|
|
141
|
+
</template>
|
|
142
|
+
</UBlogPost>
|
|
143
|
+
</UBlogPosts>
|
|
144
|
+
|
|
145
|
+
<div v-else class="all:flex flex-col items-center justify-center py-20 text-muted text-center">
|
|
146
|
+
<UIcon v-if="noResultsIcon" :name="noResultsIcon" class="size-12 mb-4 opacity-20" />
|
|
147
|
+
<p>{{ noResultsMessage }}</p>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
<div v-if="data && data.total > itemsPerPage" class="all:flex justify-center mt-8">
|
|
151
|
+
<UPagination
|
|
152
|
+
v-model:page="page"
|
|
153
|
+
:total="data.total"
|
|
154
|
+
:items-per-page="itemsPerPage"
|
|
155
|
+
/>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
</template>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import formatDate from '~/utils/formatDate'
|
|
3
|
+
|
|
4
|
+
defineProps<{
|
|
5
|
+
article: any
|
|
6
|
+
}>()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<time v-if="article.date" class="text-xs text-muted">
|
|
11
|
+
{{ formatDate(article.date) }}
|
|
12
|
+
<template v-if="article.dateEnd && article.date !== article.dateEnd">
|
|
13
|
+
- {{ formatDate(article.dateEnd) }}
|
|
14
|
+
</template>
|
|
15
|
+
</time>
|
|
16
|
+
</template>
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
const hasAuthors = has('authors')
|
|
11
|
+
const hasLinks = has('links')
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<div class="mt-4 all:flex flex-wrap items-center gap-3">
|
|
16
|
+
<HAuthors v-if="hasAuthors" :authors="page?.authors" />
|
|
17
|
+
<HLinks v-if="hasLinks && page?.links?.length" :links="page?.links" />
|
|
18
|
+
<slot />
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
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">·</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">·</span>
|
|
24
|
+
<HLocation v-if="showLocation" :location="page?.location" />
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script setup lang="ts" generic="C extends keyof PageCollections = 'article'">
|
|
2
|
+
import type { PageCollections } from '@nuxt/content'
|
|
3
|
+
import type { ArticleFilter } from '~/composables/useArticleList'
|
|
4
|
+
|
|
5
|
+
const props = withDefaults(defineProps<{
|
|
6
|
+
/** Optional fixed category to filter by */
|
|
7
|
+
category?: string
|
|
8
|
+
/** The orientation of the blog posts list */
|
|
9
|
+
orientation?: 'horizontal' | 'vertical'
|
|
10
|
+
/** The collection to fetch articles from */
|
|
11
|
+
collection?: C
|
|
12
|
+
/** Additional custom filters */
|
|
13
|
+
where?: ArticleFilter[]
|
|
14
|
+
/** Field to sort by. Set to false to disable default sorting. */
|
|
15
|
+
sort?: { field: string, direction: 'ASC' | 'DESC' } | false
|
|
16
|
+
/** Status to filter by. Set to false to disable default status filtering. */
|
|
17
|
+
status?: string | false
|
|
18
|
+
/** Optional items per page override */
|
|
19
|
+
itemsPerPage?: number
|
|
20
|
+
}>(), {
|
|
21
|
+
sort: undefined,
|
|
22
|
+
status: undefined,
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const route = useRoute()
|
|
26
|
+
|
|
27
|
+
/** Resolve the configuration for this collection using the smart merger */
|
|
28
|
+
const { config: collectionConfig } = useVariant(() => props.collection || 'article')
|
|
29
|
+
|
|
30
|
+
const labelAll = computed(() => collectionConfig.value.list?.labelAll || 'All')
|
|
31
|
+
|
|
32
|
+
const selectedCategory = ref(props.category || (route.query.category as string) || String(labelAll.value))
|
|
33
|
+
|
|
34
|
+
const categories = computed(() => {
|
|
35
|
+
const cats = collectionConfig.value.categories || {}
|
|
36
|
+
const items = [
|
|
37
|
+
{ label: String(labelAll.value), value: String(labelAll.value) },
|
|
38
|
+
...Object.keys(cats).map(key => ({
|
|
39
|
+
label: String(cats[key]?.label || key),
|
|
40
|
+
value: String(key),
|
|
41
|
+
})),
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
return items.map(item => ({
|
|
45
|
+
label: item.label,
|
|
46
|
+
active: selectedCategory.value === item.value,
|
|
47
|
+
onSelect: () => {
|
|
48
|
+
selectedCategory.value = item.value
|
|
49
|
+
updateQuery()
|
|
50
|
+
},
|
|
51
|
+
}))
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
function updateQuery() {
|
|
55
|
+
const query: Record<string, any> = { ...route.query }
|
|
56
|
+
delete query.page // Omit page 1 from query
|
|
57
|
+
|
|
58
|
+
if (selectedCategory.value !== labelAll.value)
|
|
59
|
+
query.category = selectedCategory.value
|
|
60
|
+
else
|
|
61
|
+
delete query.category
|
|
62
|
+
|
|
63
|
+
navigateTo({ query })
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Sync state with query on back/forward navigation
|
|
67
|
+
watch(() => route.query.category, (newCategory) => {
|
|
68
|
+
selectedCategory.value = (newCategory as string) || labelAll.value
|
|
69
|
+
})
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<div class="all:flex flex-col gap-8">
|
|
74
|
+
<div v-if="!props.category" class="border-b border-gray-200 dark:border-gray-800">
|
|
75
|
+
<UNavigationMenu
|
|
76
|
+
:items="categories"
|
|
77
|
+
highlight
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<HArticleGrid
|
|
82
|
+
:category="selectedCategory"
|
|
83
|
+
:orientation="props.orientation"
|
|
84
|
+
:collection="props.collection"
|
|
85
|
+
:where="props.where"
|
|
86
|
+
:sort="props.sort"
|
|
87
|
+
:status="props.status"
|
|
88
|
+
:items-per-page="props.itemsPerPage"
|
|
89
|
+
>
|
|
90
|
+
<template v-for="(_, name) in $slots" #[name]="slotData">
|
|
91
|
+
<slot :name="name" v-bind="slotData" />
|
|
92
|
+
</template>
|
|
93
|
+
</HArticleGrid>
|
|
94
|
+
</div>
|
|
95
|
+
</template>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PageCollections } from '@nuxt/content'
|
|
3
|
+
|
|
4
|
+
const { collection = 'article' } = defineProps<{
|
|
5
|
+
collection?: keyof PageCollections
|
|
6
|
+
path?: string
|
|
7
|
+
}>()
|
|
8
|
+
|
|
9
|
+
const { data: page } = await usePageContent({ collection: () => collection })
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<NuxtLayout name="article" :collection="collection">
|
|
14
|
+
<ContentRenderer v-if="page" :value="page" />
|
|
15
|
+
</NuxtLayout>
|
|
16
|
+
</template>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{
|
|
3
|
+
items: string[]
|
|
4
|
+
}>()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<UCarousel v-slot="{ item }" :items="items" :ui="{ item: 'basis-full sm:basis-1/2' }" dots>
|
|
9
|
+
<ProseImg :src="item" alt="" class="w-full rounded-lg" />
|
|
10
|
+
</UCarousel>
|
|
11
|
+
</template>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Component } from 'vue'
|
|
3
|
+
|
|
4
|
+
const props = withDefaults(defineProps<{
|
|
5
|
+
path: string
|
|
6
|
+
prose?: boolean
|
|
7
|
+
components?: Record<string, Component>
|
|
8
|
+
}>(), {
|
|
9
|
+
prose: true,
|
|
10
|
+
components: undefined,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const { data: snippet } = await useAsyncData(
|
|
14
|
+
`snippet-${props.path}`,
|
|
15
|
+
() => queryCollection('snippet')
|
|
16
|
+
.path(props.path)
|
|
17
|
+
.first(),
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
const components = computed(() => props.components)
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<ContentRenderer
|
|
25
|
+
v-if="snippet"
|
|
26
|
+
:value="snippet"
|
|
27
|
+
:prose="props.prose"
|
|
28
|
+
:components="components"
|
|
29
|
+
v-bind="$attrs"
|
|
30
|
+
/>
|
|
31
|
+
</template>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { ButtonProps } from '@nuxt/ui'
|
|
3
|
+
|
|
4
|
+
defineProps<{
|
|
5
|
+
buttons?: ButtonProps[]
|
|
6
|
+
}>()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<div>
|
|
11
|
+
<UButton v-for="(button, index) in buttons" :key="index" v-bind="button" />
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|