@blogmcp/sdk 0.6.0 → 0.7.0

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 (208) hide show
  1. package/dist/consultations/channel-text.d.ts +118 -0
  2. package/dist/consultations/channel-text.js +40 -0
  3. package/dist/consultations/index.d.ts +28 -0
  4. package/dist/consultations/index.js +60 -0
  5. package/dist/consultations/messages.cs.d.ts +149 -0
  6. package/dist/consultations/messages.cs.js +143 -0
  7. package/dist/consultations/messages.d.ts +34 -0
  8. package/dist/consultations/messages.en.d.ts +143 -0
  9. package/dist/consultations/messages.en.js +141 -0
  10. package/dist/consultations/messages.js +48 -0
  11. package/dist/consultations/outcome.d.ts +121 -0
  12. package/dist/consultations/outcome.js +161 -0
  13. package/dist/consultations/public-config.d.ts +71 -0
  14. package/dist/consultations/public-config.js +104 -0
  15. package/dist/consultations/reader.d.ts +83 -0
  16. package/dist/consultations/reader.js +128 -0
  17. package/dist/consultations/routes.d.ts +214 -0
  18. package/dist/consultations/routes.js +149 -0
  19. package/dist/consultations/server/client-ip.d.ts +50 -0
  20. package/dist/consultations/server/client-ip.js +44 -0
  21. package/dist/consultations/server/contact.d.ts +23 -0
  22. package/dist/consultations/server/contact.js +138 -0
  23. package/dist/consultations/server/context.d.ts +246 -0
  24. package/dist/consultations/server/context.js +152 -0
  25. package/dist/consultations/server/cookie.d.ts +60 -0
  26. package/dist/consultations/server/cookie.js +57 -0
  27. package/dist/consultations/server/env.d.ts +20 -0
  28. package/dist/consultations/server/env.js +35 -0
  29. package/dist/consultations/server/http.d.ts +59 -0
  30. package/dist/consultations/server/http.js +64 -0
  31. package/dist/consultations/server/index.d.ts +37 -0
  32. package/dist/consultations/server/index.js +19 -0
  33. package/dist/consultations/server/origin.d.ts +39 -0
  34. package/dist/consultations/server/origin.js +31 -0
  35. package/dist/consultations/server/server.d.ts +106 -0
  36. package/dist/consultations/server/server.js +122 -0
  37. package/dist/consultations/server/session.d.ts +38 -0
  38. package/dist/consultations/server/session.js +210 -0
  39. package/dist/consultations/server/transport.d.ts +69 -0
  40. package/dist/consultations/server/transport.js +117 -0
  41. package/dist/consultations/server/turnstile.d.ts +44 -0
  42. package/dist/consultations/server/turnstile.js +31 -0
  43. package/dist/consultations/site.d.ts +100 -0
  44. package/dist/consultations/site.js +60 -0
  45. package/dist/consultations/submit-new.d.ts +103 -0
  46. package/dist/consultations/submit-new.js +72 -0
  47. package/dist/core/auth.d.ts +2 -2
  48. package/dist/core/client.d.ts +25 -4
  49. package/dist/core/client.js +35 -30
  50. package/dist/core/consultation-adapter.d.ts +2 -2
  51. package/dist/core/consultations.d.ts +1 -1
  52. package/dist/core/errors.d.ts +1 -1
  53. package/dist/core/errors.js +16 -15
  54. package/dist/core/index.d.ts +31 -31
  55. package/dist/core/index.js +35 -34
  56. package/dist/core/markdown.d.ts +1 -1
  57. package/dist/core/queries.d.ts +4 -1
  58. package/dist/core/queries.js +131 -86
  59. package/dist/core/review/format.d.ts +1 -1
  60. package/dist/core/review/index.d.ts +2 -2
  61. package/dist/core/seo.d.ts +1 -1
  62. package/dist/core/translations/cs.json.js +1 -1
  63. package/dist/core/translations/en.json.js +1 -1
  64. package/dist/core/types.d.ts +50 -1
  65. package/dist/core/view-model.d.ts +12 -2
  66. package/dist/core/view-model.js +40 -34
  67. package/dist/{packages/tripmap-core/node_modules → node_modules}/pmtiles/dist/esm/index.js +1 -1
  68. package/dist/nuxt/composables/useAsyncKb.d.ts +4 -4
  69. package/dist/nuxt/index.d.ts +1 -1
  70. package/dist/packages/mdx-render-vue/dist/composables/useGallery.js +12 -11
  71. package/dist/packages/mdx-render-vue/dist/composables/useTripMap.js +16 -16
  72. package/dist/packages/mdx-render-vue/dist/edit/TripMapEdit.vue.js +1 -1
  73. package/dist/packages/mdx-render-vue/dist/registry.js +21 -22
  74. package/dist/packages/mdx-render-vue/dist/render/alert/Alert.vue2.js +1 -1
  75. package/dist/packages/mdx-render-vue/dist/render/badge/Badge.vue2.js +1 -1
  76. package/dist/packages/mdx-render-vue/dist/render/button/Button.vue2.js +1 -1
  77. package/dist/packages/mdx-render-vue/dist/render/callout/CalloutDefault.vue.js +1 -1
  78. package/dist/packages/mdx-render-vue/dist/render/callout/CalloutMinimal.vue.js +1 -1
  79. package/dist/packages/mdx-render-vue/dist/render/tripmap/TripMapDefault.vue.js +2 -2
  80. package/dist/packages/tripmap-core/dist/engine.js +3 -3
  81. package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +1 -1
  82. package/dist/react/KbMdxContent.d.ts +1 -1
  83. package/dist/react/KbMdxContent.js +7 -8
  84. package/dist/react/context.d.ts +4 -4
  85. package/dist/react/hooks/useImageRenderer.d.ts +1 -1
  86. package/dist/react/hooks/useKbClient.d.ts +1 -1
  87. package/dist/react/hooks/useKbContext.d.ts +1 -1
  88. package/dist/react/hooks/useKbI18n.d.ts +1 -1
  89. package/dist/react/hooks/useKbLanguage.d.ts +1 -1
  90. package/dist/react/hooks/useKbSearch.d.ts +1 -1
  91. package/dist/react/hooks/useMdxContent.d.ts +1 -1
  92. package/dist/react/index.d.ts +15 -15
  93. package/dist/react/provider.d.ts +2 -2
  94. package/dist/react/server/index.d.ts +2 -2
  95. package/dist/vue/components/KbAccessGate.vue.d.ts +4 -1
  96. package/dist/vue/components/KbAccessGate.vue.js +42 -32
  97. package/dist/vue/components/KbArticleCard.vue.d.ts +3 -1
  98. package/dist/vue/components/KbArticleCard.vue.js +67 -39
  99. package/dist/vue/components/KbMdxContent.vue2.js +6 -7
  100. package/dist/vue/composables/useArticles.d.ts +1 -1
  101. package/dist/vue/composables/useImageRenderer.d.ts +1 -1
  102. package/dist/vue/composables/useKbAuth.d.ts +1 -1
  103. package/dist/vue/composables/useKbClient.d.ts +1 -1
  104. package/dist/vue/composables/useKbComments.d.ts +1 -1
  105. package/dist/vue/composables/useKbI18n.d.ts +1 -1
  106. package/dist/vue/composables/useKbLanguage.d.ts +1 -1
  107. package/dist/vue/composables/useNavigation.d.ts +1 -1
  108. package/dist/vue/composables/useSearch.d.ts +1 -1
  109. package/dist/vue/composables/useTags.d.ts +1 -1
  110. package/dist/vue/index.d.ts +19 -19
  111. package/dist/vue/plugin.d.ts +4 -4
  112. package/package.json +15 -5
  113. package/src/consultations/channel-text.ts +168 -0
  114. package/src/consultations/index.ts +87 -0
  115. package/src/consultations/messages.cs.ts +175 -0
  116. package/src/consultations/messages.en.ts +171 -0
  117. package/src/consultations/messages.ts +91 -0
  118. package/src/consultations/outcome.ts +278 -0
  119. package/src/consultations/public-config.ts +246 -0
  120. package/src/consultations/reader.ts +281 -0
  121. package/src/consultations/routes.ts +341 -0
  122. package/src/consultations/server/client-ip.ts +106 -0
  123. package/src/consultations/server/contact.ts +267 -0
  124. package/src/consultations/server/context.ts +403 -0
  125. package/src/consultations/server/cookie.ts +129 -0
  126. package/src/consultations/server/env.ts +66 -0
  127. package/src/consultations/server/http.ts +148 -0
  128. package/src/consultations/server/index.ts +55 -0
  129. package/src/consultations/server/origin.ts +71 -0
  130. package/src/consultations/server/server.ts +322 -0
  131. package/src/consultations/server/session.ts +414 -0
  132. package/src/consultations/server/transport.ts +196 -0
  133. package/src/consultations/server/turnstile.ts +98 -0
  134. package/src/consultations/site.ts +183 -0
  135. package/src/consultations/submit-new.ts +266 -0
  136. package/src/core/auth.ts +1 -1
  137. package/src/core/client.ts +32 -1
  138. package/src/core/errors.ts +5 -2
  139. package/src/core/index.ts +3 -0
  140. package/src/core/queries.ts +56 -0
  141. package/src/core/translations/cs.json +2 -1
  142. package/src/core/translations/en.json +2 -1
  143. package/src/core/types.ts +51 -0
  144. package/src/core/view-model.ts +18 -0
  145. package/src/vue/components/KbAccessGate.vue +14 -1
  146. package/src/vue/components/KbArticleCard.vue +25 -0
  147. package/dist/_virtual/constants.js +0 -4
  148. package/dist/_virtual/index.js +0 -2
  149. package/dist/_virtual/index2.js +0 -4
  150. package/dist/_virtual/index3.js +0 -2
  151. package/dist/_virtual/re.js +0 -4
  152. package/dist/node_modules/@braintree/sanitize-url/dist/constants.js +0 -8
  153. package/dist/node_modules/@braintree/sanitize-url/dist/index.js +0 -60
  154. package/dist/node_modules/dompurify/dist/purify.es.js +0 -662
  155. package/dist/node_modules/semver/classes/comparator.js +0 -56
  156. package/dist/node_modules/semver/classes/range.js +0 -148
  157. package/dist/node_modules/semver/classes/semver.js +0 -169
  158. package/dist/node_modules/semver/functions/clean.js +0 -14
  159. package/dist/node_modules/semver/functions/cmp.js +0 -39
  160. package/dist/node_modules/semver/functions/coerce.js +0 -33
  161. package/dist/node_modules/semver/functions/compare-build.js +0 -14
  162. package/dist/node_modules/semver/functions/compare-loose.js +0 -11
  163. package/dist/node_modules/semver/functions/compare.js +0 -11
  164. package/dist/node_modules/semver/functions/diff.js +0 -24
  165. package/dist/node_modules/semver/functions/eq.js +0 -11
  166. package/dist/node_modules/semver/functions/gt.js +0 -11
  167. package/dist/node_modules/semver/functions/gte.js +0 -11
  168. package/dist/node_modules/semver/functions/inc.js +0 -21
  169. package/dist/node_modules/semver/functions/lt.js +0 -11
  170. package/dist/node_modules/semver/functions/lte.js +0 -11
  171. package/dist/node_modules/semver/functions/major.js +0 -11
  172. package/dist/node_modules/semver/functions/minor.js +0 -11
  173. package/dist/node_modules/semver/functions/neq.js +0 -11
  174. package/dist/node_modules/semver/functions/parse.js +0 -21
  175. package/dist/node_modules/semver/functions/patch.js +0 -11
  176. package/dist/node_modules/semver/functions/prerelease.js +0 -14
  177. package/dist/node_modules/semver/functions/rcompare.js +0 -11
  178. package/dist/node_modules/semver/functions/rsort.js +0 -11
  179. package/dist/node_modules/semver/functions/satisfies.js +0 -18
  180. package/dist/node_modules/semver/functions/sort.js +0 -11
  181. package/dist/node_modules/semver/functions/valid.js +0 -14
  182. package/dist/node_modules/semver/index.js +0 -97
  183. package/dist/node_modules/semver/internal/constants.js +0 -28
  184. package/dist/node_modules/semver/internal/debug.js +0 -8
  185. package/dist/node_modules/semver/internal/identifiers.js +0 -18
  186. package/dist/node_modules/semver/internal/lrucache.js +0 -32
  187. package/dist/node_modules/semver/internal/parse-options.js +0 -10
  188. package/dist/node_modules/semver/internal/re.js +0 -32
  189. package/dist/node_modules/semver/ranges/gtr.js +0 -11
  190. package/dist/node_modules/semver/ranges/intersects.js +0 -11
  191. package/dist/node_modules/semver/ranges/ltr.js +0 -11
  192. package/dist/node_modules/semver/ranges/max-satisfying.js +0 -22
  193. package/dist/node_modules/semver/ranges/min-satisfying.js +0 -22
  194. package/dist/node_modules/semver/ranges/min-version.js +0 -42
  195. package/dist/node_modules/semver/ranges/outside.js +0 -44
  196. package/dist/node_modules/semver/ranges/simplify.js +0 -24
  197. package/dist/node_modules/semver/ranges/subset.js +0 -94
  198. package/dist/node_modules/semver/ranges/to-comparators.js +0 -11
  199. package/dist/node_modules/semver/ranges/valid.js +0 -17
  200. package/dist/packages/mdx-schema/dist/composables/useMdxParsing.js +0 -389
  201. package/dist/packages/mdx-schema/dist/metadata/index.js +0 -526
  202. package/dist/packages/mdx-schema/dist/prepareProps.js +0 -46
  203. package/dist/packages/mdx-schema/dist/styles/index.js +0 -147
  204. package/dist/packages/mdx-schema/dist/tripmap.js +0 -101
  205. package/dist/packages/mdx-schema/dist/types/index.js +0 -26
  206. package/dist/packages/sanitize/dist/html.js +0 -89
  207. /package/dist/{packages/tripmap-core/node_modules → node_modules}/maplibre-gl/dist/maplibre-gl-shared.js +0 -0
  208. /package/dist/{packages/tripmap-core/node_modules → node_modules}/maplibre-gl/dist/maplibre-gl.js +0 -0
@@ -28,6 +28,32 @@ export const ACCESSIBLE_ARTICLES = `
28
28
  }
29
29
  `
30
30
 
31
+ // The same list plus the published premium/partners articles the caller may NOT open
32
+ // but the tenant shows (its locked-article preview is title or excerpt), flagged
33
+ // `locked` and carrying their tiers. A document of its own, so the default list keeps
34
+ // validating against a KB API that predates the field.
35
+ export const ACCESSIBLE_ARTICLES_WITH_LOCKED = `
36
+ query AccessibleArticlesWithLocked($status: String, $tags: [String!], $tagMode: String, $limit: Int, $offset: Int) {
37
+ accessibleKbArticles(status: $status, tags: $tags, tagMode: $tagMode, limit: $limit, offset: $offset, includeLocked: true) {
38
+ articles {
39
+ id
40
+ filename
41
+ title
42
+ description
43
+ contentType
44
+ status
45
+ publishedAt
46
+ updatedAt
47
+ tags
48
+ featuredImageUrl
49
+ access
50
+ locked
51
+ }
52
+ totalCount
53
+ }
54
+ }
55
+ `
56
+
31
57
  // Field selection shared by the by-filename and by-id article queries, so both
32
58
  // lookups always return the identical ArticleWithTranslation shape.
33
59
  const ARTICLE_WITH_TRANSLATION_FIELDS = `
@@ -82,6 +108,34 @@ export const ARTICLE_WITH_TRANSLATION_BY_ID = `
82
108
  }
83
109
  `
84
110
 
111
+ // What a reader who may NOT open a published article sees of it — or null (also for a
112
+ // reader who can open it, and whenever the tenant hides locked articles). Never the body.
113
+ const ARTICLE_PREVIEW_FIELDS = `
114
+ id
115
+ filename
116
+ title
117
+ description
118
+ languageCode
119
+ isFallback
120
+ publishedAt
121
+ featuredImageUrl
122
+ requiredAccess
123
+ mode
124
+ excerpt
125
+ `
126
+
127
+ export const ARTICLE_PREVIEW = `
128
+ query ArticlePreview($filename: String!, $languageCode: String!) {
129
+ articlePreview(filename: $filename, languageCode: $languageCode) {${ARTICLE_PREVIEW_FIELDS}}
130
+ }
131
+ `
132
+
133
+ export const ARTICLE_PREVIEW_BY_ID = `
134
+ query ArticlePreviewById($id: ID!, $languageCode: String!) {
135
+ articlePreviewById(id: $id, languageCode: $languageCode) {${ARTICLE_PREVIEW_FIELDS}}
136
+ }
137
+ `
138
+
85
139
  export const ARTICLE_ALIAS_TARGET = `
86
140
  query ArticleAliasTarget($filename: String!) {
87
141
  articleAliasTarget(filename: $filename)
@@ -486,6 +540,8 @@ export const CONSULTATION_PUBLIC_CONFIG = `
486
540
  query ConsultationPublicConfig($locale: String!) {
487
541
  consultationPublicConfig(locale: $locale) {
488
542
  enabled
543
+ readerSiteUrl
544
+ emailNotices
489
545
  channels {
490
546
  channel
491
547
  mode
@@ -167,7 +167,8 @@
167
167
  "levelPublic": "Veřejné",
168
168
  "levelPremium": "Premium",
169
169
  "levelPartners": "Partneři",
170
- "levelInternal": "Interní"
170
+ "levelInternal": "Interní",
171
+ "lockedFor": "Jen pro čtenáře úrovně {level}"
171
172
  },
172
173
  "footer": {
173
174
  "copyright": "© {year} Znalostní báze. Všechna práva vyhrazena."
@@ -167,7 +167,8 @@
167
167
  "levelPublic": "Public",
168
168
  "levelPremium": "Premium",
169
169
  "levelPartners": "Partners",
170
- "levelInternal": "Internal"
170
+ "levelInternal": "Internal",
171
+ "lockedFor": "Only for {level} readers"
171
172
  },
172
173
  "footer": {
173
174
  "copyright": "© {year} Knowledge Base. All rights reserved."
package/src/core/types.ts CHANGED
@@ -44,6 +44,44 @@ export interface Article {
44
44
  sourceLanguageCode?: string
45
45
  featuredImageUrl?: string | null
46
46
  tags?: string[]
47
+ /** Only from `articles.list({ includeLocked: true })`: the article's access tiers. */
48
+ access?: string[]
49
+ /**
50
+ * Only from `articles.list({ includeLocked: true })`: true when the caller may not open
51
+ * this article — it is listed because the tenant shows locked articles. Link it to the
52
+ * article page, which shows `articles.getPreview` instead of the article.
53
+ */
54
+ locked?: boolean
55
+ }
56
+
57
+ /** What a locked article shows to a reader without access (the tenant's choice). */
58
+ export type LockedPreviewMode = 'title' | 'excerpt'
59
+
60
+ /**
61
+ * What a reader who may NOT open a published premium or partners article sees of it
62
+ * (`articles.getPreview`). Never the article body.
63
+ */
64
+ export interface ArticlePreview {
65
+ id: string
66
+ filename: string
67
+ /** In `languageCode`. */
68
+ title: string
69
+ description: string | null
70
+ /** The language of title, description and excerpt (the source language as a fallback). */
71
+ languageCode: string
72
+ isFallback: boolean
73
+ publishedAt: string | null
74
+ /** Only when the image itself is public. */
75
+ featuredImageUrl: string | null
76
+ /** The lowest tier that opens the article. */
77
+ requiredAccess: 'premium' | 'partners'
78
+ mode: LockedPreviewMode
79
+ /**
80
+ * `excerpt` mode: the first words of the text, plain text — paragraphs separated by a
81
+ * blank line, ending with an ellipsis, never more than half the text. Render as text,
82
+ * never as HTML or Markdown. Null in `title` mode.
83
+ */
84
+ excerpt: string | null
47
85
  }
48
86
 
49
87
  export interface ArticleWithTranslation {
@@ -347,6 +385,19 @@ export interface ConsultationChannelConfig {
347
385
 
348
386
  export interface ConsultationPublicConfig {
349
387
  enabled: boolean
388
+ /**
389
+ * The reader site the KB sends readers to (its links in notice e-mails), in
390
+ * canonical form (no trailing slash); null when none is set. A blog serves
391
+ * the reader pages only when this is the blog itself
392
+ * (`readerSiteStatus` in `@blogmcp/sdk/consultations`). Needs a KB with F4.
393
+ */
394
+ readerSiteUrl: string | null
395
+ /**
396
+ * Answers reach readers by e-mail: the tenant's adapter sends them, or the KB
397
+ * has a mail transport. False: hide the anonymous contact form and the
398
+ * new-link page — nobody would ever be told about an answer.
399
+ */
400
+ emailNotices: boolean
350
401
  channels: ConsultationChannelConfig[]
351
402
  }
352
403
 
@@ -52,6 +52,18 @@ export function resolveArticleAccessLevel(
52
52
  return ACCESS_LEVEL_ORDER[maxIndex] ?? 'public'
53
53
  }
54
54
 
55
+ /**
56
+ * The lowest tier that opens a locked article (premium before partners) — what a locked
57
+ * card asks the reader for. Mirrors the KB API's rule; null when a public reader can open
58
+ * it or nobody outside the team can.
59
+ */
60
+ export function lockedRequiredAccess(access: string[] | null | undefined): 'premium' | 'partners' | null {
61
+ if (!access || access.includes('public')) return null
62
+ if (access.includes('premium')) return 'premium'
63
+ if (access.includes('partners')) return 'partners'
64
+ return null
65
+ }
66
+
55
67
  /** Render-ready view model for an article card / list item. */
56
68
  export interface ArticleListItemVM {
57
69
  slug: string
@@ -66,6 +78,10 @@ export interface ArticleListItemVM {
66
78
  /** Localized human date, or null when no date is available. */
67
79
  formattedDate: string | null
68
80
  tags: { label: string; slug: string; href: string }[]
81
+ /** The reader may not open the article (listed with `includeLocked`): show a lock. */
82
+ locked: boolean
83
+ /** For a locked article, the tier that opens it; null otherwise. */
84
+ requiredAccess: 'premium' | 'partners' | null
69
85
  }
70
86
 
71
87
  export interface BuildArticleListItemOptions {
@@ -94,5 +110,7 @@ export function buildArticleListItem(opts: BuildArticleListItemOptions): Article
94
110
  slug: tag,
95
111
  href: localizedHref(`/topics/${tag}`, locale, config),
96
112
  })),
113
+ locked: article.locked === true,
114
+ requiredAccess: article.locked === true ? lockedRequiredAccess(article.access) : null,
97
115
  }
98
116
  }
@@ -4,6 +4,10 @@
4
4
  *
5
5
  * Blocks content access for insufficient access levels.
6
6
  * Provides state via slot props for custom rendering.
7
+ *
8
+ * Feed it `articles.getPreview(...)` to show what the tenant lets a reader without access
9
+ * see — the title and description, and in excerpt mode the first words of the article
10
+ * (plain text: rendered as text paragraphs, never as HTML).
7
11
  */
8
12
 
9
13
  import { computed } from 'vue'
@@ -12,7 +16,7 @@ import { useKbAuth } from '../composables/useKbAuth'
12
16
  import { useKbI18n } from '../composables/useKbI18n'
13
17
 
14
18
  const props = defineProps<{
15
- article: { title: string; description?: string | null }
19
+ article: { title: string; description?: string | null; excerpt?: string | null }
16
20
  requiredLevel: AccessLevel
17
21
  }>()
18
22
 
@@ -27,6 +31,11 @@ const t = useKbI18n()
27
31
 
28
32
  const levelLabel = computed(() => t(`accessGate.level${capitalize(props.requiredLevel)}`))
29
33
 
34
+ /** The excerpt's paragraphs (separated by a blank line in the preview). */
35
+ const excerptParagraphs = computed(() =>
36
+ (props.article.excerpt ?? '').split(/\n\s*\n/).map((p) => p.trim()).filter(Boolean),
37
+ )
38
+
30
39
  function capitalize(s: string): string {
31
40
  return s.charAt(0).toUpperCase() + s.slice(1)
32
41
  }
@@ -38,6 +47,7 @@ function capitalize(s: string): string {
38
47
  :required-level="requiredLevel"
39
48
  :level-label="levelLabel"
40
49
  :is-authenticated="isAuthenticated"
50
+ :excerpt-paragraphs="excerptParagraphs"
41
51
  >
42
52
  <!-- Default rendering -->
43
53
  <div
@@ -51,6 +61,9 @@ function capitalize(s: string): string {
51
61
  </div>
52
62
  <h2 class="mt-6 text-2xl font-bold text-gray-900">{{ article.title }}</h2>
53
63
  <p v-if="article.description" class="mt-2 text-gray-600">{{ article.description }}</p>
64
+ <div v-if="excerptParagraphs.length" data-testid="access-gate-excerpt" class="mt-6 space-y-3 text-left text-gray-700">
65
+ <p v-for="(paragraph, index) in excerptParagraphs" :key="index">{{ paragraph }}</p>
66
+ </div>
54
67
  <p class="mt-6 text-gray-600">
55
68
  <template v-if="!isAuthenticated">
56
69
  {{ t('accessGate.signInToAccess', { level: levelLabel }) }}
@@ -5,10 +5,15 @@
5
5
  * Provides article data and computed properties via slot props.
6
6
  * Consumer controls rendering via the default slot.
7
7
  * Falls back to a basic pre-styled card if no slot is provided.
8
+ *
9
+ * A locked article (from `articles.list({ includeLocked: true })`) carries a lock and the
10
+ * tier that opens it; its link still goes to the article page, which shows the gate.
8
11
  */
9
12
 
10
13
  import { computed } from 'vue'
11
14
  import type { Article } from '../../core/types'
15
+ import { lockedRequiredAccess } from '../../core/view-model'
16
+ import { useKbI18n } from '../composables/useKbI18n'
12
17
 
13
18
  const props = withDefaults(defineProps<{
14
19
  article: Article
@@ -31,6 +36,13 @@ const articleUrl = computed(() => `/articles/${slug.value}`)
31
36
 
32
37
  const tags = computed(() => props.article.tags || [])
33
38
 
39
+ const t = useKbI18n()
40
+ const locked = computed(() => props.article.locked === true)
41
+ const requiredAccess = computed(() => (locked.value ? lockedRequiredAccess(props.article.access) : null))
42
+ const lockedLabel = computed(() =>
43
+ requiredAccess.value ? t(`accessGate.level${requiredAccess.value === 'premium' ? 'Premium' : 'Partners'}`) : null,
44
+ )
45
+
34
46
  function formatDate(dateString: string): string {
35
47
  const loc = props.locale === 'cs' ? 'cs-CZ' : 'en-US'
36
48
  return new Date(dateString).toLocaleDateString(loc, {
@@ -55,6 +67,8 @@ const displayDate = computed(() => {
55
67
  :display-date="displayDate"
56
68
  :featured="featured"
57
69
  :format-date="formatDate"
70
+ :locked="locked"
71
+ :required-access="requiredAccess"
58
72
  >
59
73
  <!-- Default rendering (basic card) -->
60
74
  <article
@@ -85,6 +99,17 @@ const displayDate = computed(() => {
85
99
  {{ tag }}
86
100
  </span>
87
101
  </div>
102
+ <span
103
+ v-if="locked"
104
+ data-testid="article-card-locked"
105
+ class="mb-2 inline-flex w-fit items-center gap-1 rounded-full bg-amber-50 px-2.5 py-0.5 text-xs font-medium text-amber-700"
106
+ :aria-label="t('accessGate.lockedFor', { level: lockedLabel ?? '' })"
107
+ >
108
+ <svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
109
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
110
+ </svg>
111
+ {{ lockedLabel }}
112
+ </span>
88
113
  <h3 :class="['font-semibold text-gray-900', featured ? 'text-xl md:text-2xl' : 'text-lg']">
89
114
  <a :href="articleUrl" class="after:absolute after:inset-0">
90
115
  {{ article.title }}
@@ -1,4 +0,0 @@
1
- var s = {};
2
- export {
3
- s as __exports
4
- };
@@ -1,2 +0,0 @@
1
- import { __require as r } from "../node_modules/@braintree/sanitize-url/dist/index.js";
2
- r();
@@ -1,4 +0,0 @@
1
- var r = {};
2
- export {
3
- r as __exports
4
- };
@@ -1,2 +0,0 @@
1
- import { __require as r } from "../node_modules/semver/index.js";
2
- r();
@@ -1,4 +0,0 @@
1
- var e = { exports: {} };
2
- export {
3
- e as __module
4
- };
@@ -1,8 +0,0 @@
1
- import { __exports as e } from "../../../../_virtual/constants.js";
2
- var t;
3
- function a() {
4
- return t ? e : (t = 1, Object.defineProperty(e, "__esModule", { value: !0 }), e.BLANK_URL = e.relativeFirstCharacters = e.whitespaceEscapeCharsRegex = e.urlSchemeRegex = e.ctrlCharactersRegex = e.htmlCtrlEntityRegex = e.htmlEntitiesRegex = e.invalidProtocolRegex = void 0, e.invalidProtocolRegex = /^([^\w]*)(javascript|data|vbscript)/im, e.htmlEntitiesRegex = /&#(\w+)(^\w|;)?/g, e.htmlCtrlEntityRegex = /&(newline|tab);/gi, e.ctrlCharactersRegex = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim, e.urlSchemeRegex = /^.+(:|&colon;)/gim, e.whitespaceEscapeCharsRegex = /(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g, e.relativeFirstCharacters = [".", "/"], e.BLANK_URL = "about:blank", e);
5
- }
6
- export {
7
- a as __require
8
- };
@@ -1,60 +0,0 @@
1
- import { __exports as s } from "../../../../_virtual/index2.js";
2
- import { __require as v } from "./constants.js";
3
- var m;
4
- function U() {
5
- if (m) return s;
6
- m = 1, Object.defineProperty(s, "__esModule", { value: !0 }), s.sanitizeUrl = p;
7
- var e = v();
8
- function d(r) {
9
- return e.relativeFirstCharacters.indexOf(r[0]) > -1;
10
- }
11
- function R(r) {
12
- var i = r.replace(e.ctrlCharactersRegex, "");
13
- return i.replace(e.htmlEntitiesRegex, function(t, a) {
14
- return String.fromCharCode(a);
15
- });
16
- }
17
- function f(r) {
18
- return URL.canParse(r);
19
- }
20
- function l(r) {
21
- try {
22
- return decodeURIComponent(r);
23
- } catch {
24
- return r;
25
- }
26
- }
27
- function p(r) {
28
- if (!r)
29
- return e.BLANK_URL;
30
- var i, t = l(r.trim());
31
- do
32
- t = R(t).replace(e.htmlCtrlEntityRegex, "").replace(e.ctrlCharactersRegex, "").replace(e.whitespaceEscapeCharsRegex, "").trim(), t = l(t), i = t.match(e.ctrlCharactersRegex) || t.match(e.htmlEntitiesRegex) || t.match(e.htmlCtrlEntityRegex) || t.match(e.whitespaceEscapeCharsRegex);
33
- while (i && i.length > 0);
34
- var a = t;
35
- if (!a)
36
- return e.BLANK_URL;
37
- if (d(a))
38
- return a;
39
- var h = a.trimStart(), u = h.match(e.urlSchemeRegex);
40
- if (!u)
41
- return a;
42
- var n = u[0].toLowerCase().trim();
43
- if (e.invalidProtocolRegex.test(n))
44
- return e.BLANK_URL;
45
- var c = h.replace(/\\/g, "/");
46
- if (n === "mailto:" || n.includes("://"))
47
- return c;
48
- if (n === "http:" || n === "https:") {
49
- if (!f(c))
50
- return e.BLANK_URL;
51
- var o = new URL(c);
52
- return o.protocol = o.protocol.toLowerCase(), o.hostname = o.hostname.toLowerCase(), o.toString();
53
- }
54
- return c;
55
- }
56
- return s;
57
- }
58
- export {
59
- U as __require
60
- };