| @@ -1,10 +1,9 @@ | ||
| 1 | -import { updatePage } from '@auto-launch/functions/pages'; | |
| 1 | +import { sectionSlug, updatePage } from '@auto-launch/functions/pages'; | |
| 2 | 2 | import { alreadyActive } from '@auto-launch/functions/plugins'; |
| 3 | 3 | import { getOption, getPageById } from '@auto-launch/functions/wp'; |
| 4 | 4 | import { AI_HOST } from '@constants'; |
| 5 | 5 | import { reqDataBasics } from '@shared/lib/data'; |
| 6 | -import { pageNames } from '@shared/lib/pages'; | |
| 7 | 6 | import { getBlockContent, parse } from '@wordpress/blocks'; |
| 8 | 7 | |
| 9 | 8 | const { homeUrl } = window.extSharedData; |
| 10 | 9 | const buttonRegex = /href="(#extendify-[\w-]+)"/gi; |
| @@ -162,20 +161,12 @@ | ||
| 162 | 161 | }; |
| 163 | 162 | } |
| 164 | 163 | |
| 165 | 164 | // get all the patterns that we have in the home page |
| 166 | - const patternTypes = pages?.[0]?.patterns | |
| 167 | - ?.map((pattern) => pattern?.patternTypes?.[0]) | |
| 168 | - ?.filter((patternType) => patternType !== 'hero-header') | |
| 169 | - ?.map((patternType) => { | |
| 170 | - const { slug } = | |
| 171 | - Object.values(pageNames).find(({ alias }) => | |
| 172 | - alias.includes(patternType), | |
| 173 | - ) || {}; | |
| 174 | - return slug; | |
| 175 | - }) | |
| 176 | - ?.filter(Boolean) | |
| 177 | - ?.flat(); | |
| 165 | + const sectionSlugs = pages?.[0]?.patterns | |
| 166 | + ?.filter((pattern) => pattern?.patternTypes?.[0] !== 'hero-header') | |
| 167 | + ?.map(sectionSlug) | |
| 168 | + ?.filter(Boolean); | |
| 178 | 169 | |
| 179 | 170 | const createdPages = |
| 180 | 171 | pages |
| 181 | 172 | ?.filter((page) => page.slug !== 'home') |
| @@ -198,9 +189,9 @@ | ||
| 198 | 189 | if (alreadyActive(activePlugins, 'the-events-calendar')) { |
| 199 | 190 | pluginPages.push('events'); |
| 200 | 191 | } |
| 201 | 192 | |
| 202 | - const allAvailablePages = (patternTypes ?? []).concat(pluginPages); | |
| 193 | + const allAvailablePages = (sectionSlugs ?? []).concat(pluginPages); | |
| 203 | 194 | if (!allAvailablePages.length) { |
| 204 | 195 | wpPages[0] = updatePage({ |
| 205 | 196 | id: wpPages[0].id, |
| 206 | 197 | content: homePageContent.replaceAll( |