diff --git a/packages/vue/src/templates/edu/PageEduLesson/PageEduLesson.stories.js b/packages/vue/src/templates/edu/PageEduLesson/PageEduLesson.stories.js index e5e47988..6c9d079c 100644 --- a/packages/vue/src/templates/edu/PageEduLesson/PageEduLesson.stories.js +++ b/packages/vue/src/templates/edu/PageEduLesson/PageEduLesson.stories.js @@ -152,7 +152,7 @@ export const BaseStory = { } ], - overview: BlockStreamfieldMinimalData.body, + overview: [], overviewHeading: 'Custom Overview heading', overviewImage: BlockImageData.image, diff --git a/packages/vue/src/templates/edu/PageEduLesson/PageEduLesson.vue b/packages/vue/src/templates/edu/PageEduLesson/PageEduLesson.vue index 84265a6a..ef7bdaff 100644 --- a/packages/vue/src/templates/edu/PageEduLesson/PageEduLesson.vue +++ b/packages/vue/src/templates/edu/PageEduLesson/PageEduLesson.vue @@ -130,13 +130,16 @@ const sectionOrder = [ const staticSectionHeadings = computed((): { [key: string]: BlockHeadingObject } | undefined => { if (data) { const result = sectionOrder.reduce>((acc, section) => { - const headingText = - section === 'techAddons' - ? 'Tech Add-ons' - : section.charAt(0).toUpperCase() + section.slice(1) - acc[section] = stringAsHeadingBlockData( - (data[`${section}Heading`] as HeadingLevel) || headingText - ) + // only include the heading if the section has content + if (data[section]?.length) { + const headingText = + section === 'techAddons' + ? 'Tech Add-ons' + : section.charAt(0).toUpperCase() + section.slice(1) + acc[section] = stringAsHeadingBlockData( + (data[`${section}Heading`] as HeadingLevel) || headingText + ) + } return acc }, {}) return result @@ -243,7 +246,7 @@ const consolidatedSections = computed((): EduLessonSectionObject[] => { sections.push({ type: 'streamfield', blocks: keyedCustomSections.value['bottom'] }) } const filteredSections = sections.filter( - (item) => item.text !== undefined || item.blocks !== undefined || item.procedures !== undefined + (item) => item.text || item.blocks?.length || item.procedures?.length ) return filteredSections @@ -335,20 +338,18 @@ const consolidatedSections = computed((): EduLessonSectionObject[] => { v-for="(value, _key) in consolidatedSections" :key="_key" > - + + diff --git a/packages/vue/src/utils/generateHash.ts b/packages/vue/src/utils/generateHash.ts new file mode 100644 index 00000000..d7f1e413 --- /dev/null +++ b/packages/vue/src/utils/generateHash.ts @@ -0,0 +1,9 @@ +export function generateHash(str: string): number { + let hash = 0 + for (let i = 0, len = str.length; i < len; i++) { + let chr = str.charCodeAt(i) + hash = (hash << 5) - hash + chr + hash |= 0 // Convert to 32bit integer + } + return hash +}