@duffcloudservices/cms 0.3.12 → 0.3.14
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 +332 -309
- package/dist/editor/editorBridge.js +127 -50
- package/dist/editor/editorBridge.js.map +1 -1
- package/dist/index.js +59 -13
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.js.map +1 -1
- package/package.json +90 -90
- package/src/components/DcsReviewShowcase.vue +321 -326
- package/src/components/PreviewRibbon.vue +612 -612
- package/src/components/ResponsiveImage.vue +55 -55
- package/src/composables/index.ts +10 -10
- package/src/composables/useMediaCarousel.ts +158 -158
- package/src/composables/useReleaseNotes.ts +153 -153
- package/src/composables/useResponsiveImage.ts +85 -85
- package/src/composables/useReviewContent.ts +150 -92
- package/src/composables/useSEO.ts +387 -387
- package/src/composables/useSiteVersion.ts +123 -123
- package/src/composables/useTextContent.ts +297 -297
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* useSiteVersion Composable
|
|
3
|
-
*
|
|
4
|
-
* Gets the current site version for footer badges and version displays.
|
|
5
|
-
* Fetches the latest release version from the DCS Portal API.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```vue
|
|
9
|
-
* <script setup lang="ts">
|
|
10
|
-
* import { useSiteVersion } from '@duffcloudservices/cms'
|
|
11
|
-
*
|
|
12
|
-
* const { version, releaseNotesUrl } = useSiteVersion()
|
|
13
|
-
* </script>
|
|
14
|
-
*
|
|
15
|
-
* <template>
|
|
16
|
-
* <footer>
|
|
17
|
-
* <a v-if="version" :href="releaseNotesUrl" class="version-badge">
|
|
18
|
-
* v{{ version }}
|
|
19
|
-
* </a>
|
|
20
|
-
* </footer>
|
|
21
|
-
* </template>
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import { ref, computed, onMounted } from 'vue'
|
|
26
|
-
import type { SiteVersionReturn } from '../types/release-notes'
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Get environment variable value.
|
|
30
|
-
*/
|
|
31
|
-
function getEnvVar(key: string, defaultValue = ''): string {
|
|
32
|
-
try {
|
|
33
|
-
if (typeof import.meta !== 'undefined' && import.meta.env) {
|
|
34
|
-
const value = (import.meta.env as Record<string, string | undefined>)[key]
|
|
35
|
-
if (value !== undefined) return value
|
|
36
|
-
}
|
|
37
|
-
} catch {
|
|
38
|
-
// import.meta not available
|
|
39
|
-
}
|
|
40
|
-
return defaultValue
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Cache for site version
|
|
44
|
-
let versionCache: { version: string; expiresAt: number } | null = null
|
|
45
|
-
const CACHE_TTL = 10 * 60 * 1000 // 10 minutes
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* useSiteVersion composable for displaying the current site version.
|
|
49
|
-
*
|
|
50
|
-
* @param options - Optional configuration
|
|
51
|
-
* @returns Site version data and computed URL
|
|
52
|
-
*/
|
|
53
|
-
export function useSiteVersion(options: { fetchOnMount?: boolean } = {}): SiteVersionReturn {
|
|
54
|
-
const { fetchOnMount = true } = options
|
|
55
|
-
|
|
56
|
-
const apiBaseUrl = getEnvVar('VITE_API_BASE_URL', 'https://portal.duffcloudservices.com')
|
|
57
|
-
const siteSlug = getEnvVar('VITE_SITE_SLUG', '')
|
|
58
|
-
|
|
59
|
-
const version = ref<string | null>(null)
|
|
60
|
-
const isLoading = ref(false)
|
|
61
|
-
|
|
62
|
-
const releaseNotesUrl = computed(() => {
|
|
63
|
-
if (!version.value) return '/releaseNotes/latest'
|
|
64
|
-
return `/releaseNotes/${version.value}`
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
async function fetchVersion(): Promise<void> {
|
|
68
|
-
if (!siteSlug) {
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Check cache
|
|
73
|
-
if (versionCache && versionCache.expiresAt > Date.now()) {
|
|
74
|
-
version.value = versionCache.version
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
isLoading.value = true
|
|
79
|
-
|
|
80
|
-
try {
|
|
81
|
-
// Fetch the latest release notes to get the version
|
|
82
|
-
const url = `${apiBaseUrl}/api/v1/sites/${siteSlug}/release-notes/latest`
|
|
83
|
-
const response = await fetch(url, {
|
|
84
|
-
headers: {
|
|
85
|
-
Accept: 'application/json',
|
|
86
|
-
},
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
if (!response.ok) {
|
|
90
|
-
// No release notes yet - that's fine
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const data = await response.json()
|
|
95
|
-
const latestVersion = data.version
|
|
96
|
-
|
|
97
|
-
// Cache the result
|
|
98
|
-
versionCache = {
|
|
99
|
-
version: latestVersion,
|
|
100
|
-
expiresAt: Date.now() + CACHE_TTL,
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
version.value = latestVersion
|
|
104
|
-
} catch (e) {
|
|
105
|
-
console.error('[@duffcloudservices/cms] Failed to fetch site version:', e)
|
|
106
|
-
} finally {
|
|
107
|
-
isLoading.value = false
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Fetch on mount if enabled
|
|
112
|
-
if (fetchOnMount && typeof window !== 'undefined') {
|
|
113
|
-
onMounted(() => {
|
|
114
|
-
fetchVersion()
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
version,
|
|
120
|
-
isLoading,
|
|
121
|
-
releaseNotesUrl,
|
|
122
|
-
}
|
|
123
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* useSiteVersion Composable
|
|
3
|
+
*
|
|
4
|
+
* Gets the current site version for footer badges and version displays.
|
|
5
|
+
* Fetches the latest release version from the DCS Portal API.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```vue
|
|
9
|
+
* <script setup lang="ts">
|
|
10
|
+
* import { useSiteVersion } from '@duffcloudservices/cms'
|
|
11
|
+
*
|
|
12
|
+
* const { version, releaseNotesUrl } = useSiteVersion()
|
|
13
|
+
* </script>
|
|
14
|
+
*
|
|
15
|
+
* <template>
|
|
16
|
+
* <footer>
|
|
17
|
+
* <a v-if="version" :href="releaseNotesUrl" class="version-badge">
|
|
18
|
+
* v{{ version }}
|
|
19
|
+
* </a>
|
|
20
|
+
* </footer>
|
|
21
|
+
* </template>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { ref, computed, onMounted } from 'vue'
|
|
26
|
+
import type { SiteVersionReturn } from '../types/release-notes'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get environment variable value.
|
|
30
|
+
*/
|
|
31
|
+
function getEnvVar(key: string, defaultValue = ''): string {
|
|
32
|
+
try {
|
|
33
|
+
if (typeof import.meta !== 'undefined' && import.meta.env) {
|
|
34
|
+
const value = (import.meta.env as Record<string, string | undefined>)[key]
|
|
35
|
+
if (value !== undefined) return value
|
|
36
|
+
}
|
|
37
|
+
} catch {
|
|
38
|
+
// import.meta not available
|
|
39
|
+
}
|
|
40
|
+
return defaultValue
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Cache for site version
|
|
44
|
+
let versionCache: { version: string; expiresAt: number } | null = null
|
|
45
|
+
const CACHE_TTL = 10 * 60 * 1000 // 10 minutes
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* useSiteVersion composable for displaying the current site version.
|
|
49
|
+
*
|
|
50
|
+
* @param options - Optional configuration
|
|
51
|
+
* @returns Site version data and computed URL
|
|
52
|
+
*/
|
|
53
|
+
export function useSiteVersion(options: { fetchOnMount?: boolean } = {}): SiteVersionReturn {
|
|
54
|
+
const { fetchOnMount = true } = options
|
|
55
|
+
|
|
56
|
+
const apiBaseUrl = getEnvVar('VITE_API_BASE_URL', 'https://portal.duffcloudservices.com')
|
|
57
|
+
const siteSlug = getEnvVar('VITE_SITE_SLUG', '')
|
|
58
|
+
|
|
59
|
+
const version = ref<string | null>(null)
|
|
60
|
+
const isLoading = ref(false)
|
|
61
|
+
|
|
62
|
+
const releaseNotesUrl = computed(() => {
|
|
63
|
+
if (!version.value) return '/releaseNotes/latest'
|
|
64
|
+
return `/releaseNotes/${version.value}`
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
async function fetchVersion(): Promise<void> {
|
|
68
|
+
if (!siteSlug) {
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Check cache
|
|
73
|
+
if (versionCache && versionCache.expiresAt > Date.now()) {
|
|
74
|
+
version.value = versionCache.version
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
isLoading.value = true
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
// Fetch the latest release notes to get the version
|
|
82
|
+
const url = `${apiBaseUrl}/api/v1/sites/${siteSlug}/release-notes/latest`
|
|
83
|
+
const response = await fetch(url, {
|
|
84
|
+
headers: {
|
|
85
|
+
Accept: 'application/json',
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
if (!response.ok) {
|
|
90
|
+
// No release notes yet - that's fine
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const data = await response.json()
|
|
95
|
+
const latestVersion = data.version
|
|
96
|
+
|
|
97
|
+
// Cache the result
|
|
98
|
+
versionCache = {
|
|
99
|
+
version: latestVersion,
|
|
100
|
+
expiresAt: Date.now() + CACHE_TTL,
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
version.value = latestVersion
|
|
104
|
+
} catch (e) {
|
|
105
|
+
console.error('[@duffcloudservices/cms] Failed to fetch site version:', e)
|
|
106
|
+
} finally {
|
|
107
|
+
isLoading.value = false
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Fetch on mount if enabled
|
|
112
|
+
if (fetchOnMount && typeof window !== 'undefined') {
|
|
113
|
+
onMounted(() => {
|
|
114
|
+
fetchVersion()
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
version,
|
|
120
|
+
isLoading,
|
|
121
|
+
releaseNotesUrl,
|
|
122
|
+
}
|
|
123
|
+
}
|