@explorer-1/vue 0.2.44 → 0.2.45

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@explorer-1/vue",
3
- "version": "0.2.44",
3
+ "version": "0.2.45",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -152,7 +152,7 @@ export const BaseStory = {
152
152
  }
153
153
  ],
154
154
 
155
- overview: BlockStreamfieldMinimalData.body,
155
+ overview: [],
156
156
  overviewHeading: 'Custom Overview heading',
157
157
  overviewImage: BlockImageData.image,
158
158
 
@@ -130,13 +130,16 @@ const sectionOrder = [
130
130
  const staticSectionHeadings = computed((): { [key: string]: BlockHeadingObject } | undefined => {
131
131
  if (data) {
132
132
  const result = sectionOrder.reduce<Record<string, BlockHeadingObject>>((acc, section) => {
133
- const headingText =
134
- section === 'techAddons'
135
- ? 'Tech Add-ons'
136
- : section.charAt(0).toUpperCase() + section.slice(1)
137
- acc[section] = stringAsHeadingBlockData(
138
- (data[`${section}Heading`] as HeadingLevel) || headingText
139
- )
133
+ // only include the heading if the section has content
134
+ if (data[section]?.length) {
135
+ const headingText =
136
+ section === 'techAddons'
137
+ ? 'Tech Add-ons'
138
+ : section.charAt(0).toUpperCase() + section.slice(1)
139
+ acc[section] = stringAsHeadingBlockData(
140
+ (data[`${section}Heading`] as HeadingLevel) || headingText
141
+ )
142
+ }
140
143
  return acc
141
144
  }, {})
142
145
  return result
@@ -243,7 +246,7 @@ const consolidatedSections = computed((): EduLessonSectionObject[] => {
243
246
  sections.push({ type: 'streamfield', blocks: keyedCustomSections.value['bottom'] })
244
247
  }
245
248
  const filteredSections = sections.filter(
246
- (item) => item.text !== undefined || item.blocks !== undefined || item.procedures !== undefined
249
+ (item) => item.text || item.blocks?.length || item.procedures?.length
247
250
  )
248
251
 
249
252
  return filteredSections
@@ -335,20 +338,18 @@ const consolidatedSections = computed((): EduLessonSectionObject[] => {
335
338
  v-for="(value, _key) in consolidatedSections"
336
339
  :key="_key"
337
340
  >
338
- <template v-if="value.blocks?.length || value.procedures?.length || value.text?.length">
339
- <BlockStreamfield
340
- v-if="value.type === 'streamfield'"
341
- :data="value.blocks"
342
- />
343
- <PageEduLessonSection
344
- v-else
345
- :heading="value.heading"
346
- :blocks="value.blocks"
347
- :procedures="value.procedures"
348
- :text="value.text"
349
- :image="value.image"
350
- />
351
- </template>
341
+ <BlockStreamfield
342
+ v-if="value.type === 'streamfield'"
343
+ :data="value.blocks"
344
+ />
345
+ <PageEduLessonSection
346
+ v-else
347
+ :heading="value.heading"
348
+ :blocks="value.blocks"
349
+ :procedures="value.procedures"
350
+ :text="value.text"
351
+ :image="value.image"
352
+ />
352
353
  </template>
353
354
 
354
355
  <!-- streamfield blocks -->
@@ -0,0 +1,9 @@
1
+ export function generateHash(str: string): number {
2
+ let hash = 0
3
+ for (let i = 0, len = str.length; i < len; i++) {
4
+ let chr = str.charCodeAt(i)
5
+ hash = (hash << 5) - hash + chr
6
+ hash |= 0 // Convert to 32bit integer
7
+ }
8
+ return hash
9
+ }