| @@ -83,8 +83,9 @@ | ||
| 83 | 83 | CTALink, |
| 84 | 84 | siteObjective, |
| 85 | 85 | siteQA, |
| 86 | 86 | urlParameters, |
| 87 | + setSiteStrings, | |
| 87 | 88 | } = useUserSelectionStore(); |
| 88 | 89 | const { pages, style, removeAll, add } = usePagesSelectionStore(); |
| 89 | 90 | const [info, setInfo] = useState([ |
| 90 | 91 | __('Preparing to build your site', 'extendify-local'), |
| @@ -329,14 +330,23 @@ | ||
| 329 | 330 | id: 'home', |
| 330 | 331 | patterns: style.patterns, |
| 331 | 332 | slug: 'home', |
| 332 | 333 | }; |
| 333 | - const blogPage = { | |
| 334 | - name: pageNames.blog.title, | |
| 335 | - id: 'blog', | |
| 336 | - patterns: [], | |
| 337 | - slug: 'blog', | |
| 338 | - }; | |
| 334 | + // Home's blog section leaves posts unreachable without a posts page. | |
| 335 | + const needsBlog = | |
| 336 | + hasBlogGoal || | |
| 337 | + homePage.patterns?.some((pattern) => | |
| 338 | + pattern.patternTypes?.includes('blog-section'), | |
| 339 | + ); | |
| 340 | + const blogPage = | |
| 341 | + needsBlog && !pages.some(({ slug }) => slug === 'blog') | |
| 342 | + ? { | |
| 343 | + name: pageNames.blog.title, | |
| 344 | + id: 'blog', | |
| 345 | + patterns: [], | |
| 346 | + slug: 'blog', | |
| 347 | + } | |
| 348 | + : null; | |
| 339 | 349 | |
| 340 | 350 | await waitFor200Response(); |
| 341 | 351 | |
| 342 | 352 | inform(__('Adding page content', 'extendify-local')); |
| @@ -370,13 +380,9 @@ | ||
| 370 | 380 | const pagesToUse = hasPageWithTitleTemplate |
| 371 | 381 | ? pagesWithoutPageTitlePattern |
| 372 | 382 | : pages; |
| 373 | 383 | |
| 374 | - const pagesToCreate = [ | |
| 375 | - ...pagesToUse, | |
| 376 | - homePage, | |
| 377 | - hasBlogGoal ? blogPage : null, | |
| 378 | - ].filter(Boolean); | |
| 384 | + const pagesToCreate = [...pagesToUse, homePage, blogPage].filter(Boolean); | |
| 379 | 385 | |
| 380 | 386 | const pagesWithReplacedPatterns = []; |
| 381 | 387 | // Run these one page at a time so we don't end up with duplicate dependency issues |
| 382 | 388 | for (const page of pagesToCreate) { |
| @@ -396,18 +402,27 @@ | ||
| 396 | 402 | }, |
| 397 | 403 | siteProfile, |
| 398 | 404 | ); |
| 399 | 405 | |
| 406 | + const createdHomePage = pagesWithCustomContent.find( | |
| 407 | + (p) => p.slug === 'home', | |
| 408 | + ); | |
| 409 | + const heroPattern = createdHomePage?.patterns?.find((p) => | |
| 410 | + p.patternTypes?.includes('hero-header'), | |
| 411 | + ); | |
| 412 | + const pMatch = heroPattern?.code?.match(/<p[^>]*>([\s\S]*?)<\/p>/); | |
| 413 | + const heroDesc = pMatch?.[1]?.replace(/<[^>]+>/g, '').trim(); | |
| 414 | + setSiteStrings({ | |
| 415 | + ...siteStrings, | |
| 416 | + heroDescription: heroDesc || siteStrings?.heroDescription, | |
| 417 | + }); | |
| 418 | + | |
| 400 | 419 | const createdPages = await createWpPages(pagesWithCustomContent, { |
| 401 | 420 | stickyNav: |
| 402 | 421 | siteStructure === 'single-page' && siteObjective !== 'landing-page', |
| 403 | 422 | }); |
| 404 | 423 | |
| 405 | - const hasBlogPattern = homePage?.patterns?.some((pattern) => | |
| 406 | - pattern.patternTypes.includes('blog-section'), | |
| 407 | - ); | |
| 408 | - | |
| 409 | - if (hasBlogGoal || hasBlogPattern) { | |
| 424 | + if (needsBlog) { | |
| 410 | 425 | informDesc(__('Creating blog sample data', 'extendify-local')); |
| 411 | 426 | await createBlogSampleData(siteStrings, siteImages); |
| 412 | 427 | } |
| 413 | 428 | |
| @@ -435,13 +450,11 @@ | ||
| 435 | 450 | setPagesToAnimate([]); |
| 436 | 451 | await waitFor200Response(); |
| 437 | 452 | informDesc(__('Setting up site layout', 'extendify-local')); |
| 438 | 453 | |
| 439 | - const navPagesMultiPageSite = [ | |
| 440 | - ...pages, | |
| 441 | - hasBlogGoal ? blogPage : null, | |
| 442 | - homePage, | |
| 443 | - ].filter(Boolean); | |
| 454 | + const navPagesMultiPageSite = [...pages, blogPage, homePage].filter( | |
| 455 | + Boolean, | |
| 456 | + ); | |
| 444 | 457 | |
| 445 | 458 | const pluginPages = []; |
| 446 | 459 | |
| 447 | 460 | // Fetch active plugins after installing plugins |
| @@ -615,8 +628,9 @@ | ||
| 615 | 628 | CTALink, |
| 616 | 629 | logoUrl, |
| 617 | 630 | sitePlugins, |
| 618 | 631 | siteQA, |
| 632 | + setSiteStrings, | |
| 619 | 633 | ]); |
| 620 | 634 | |
| 621 | 635 | useEffect(() => { |
| 622 | 636 | if (logoLoading) return; |