Skip to content

Conversation

@emmadesilva
Copy link
Member

@emmadesilva emmadesilva commented Nov 16, 2024

Abstract

This PR enhances the documentation search page title to be more dynamic and natural-sounding by intelligently using the configured sidebar header while maintaining proper grammar and readability.

Motivation

The current static title "Search the documentation site" doesn't reflect the site's branding and isn't customizable. While we could directly use the sidebar header configuration, this could lead to awkward phrasing (e.g., "Search HydePHP Docs"). This PR implements a smart solution that maintains branding while ensuring natural language.

Implementation Details

  • The search page title now uses the docs.sidebar.header configuration value
  • Implements smart text transformation:
    • When the header ends with "Docs", it's transformed to "Search the [Name] Documentation"
    • Otherwise, it simply prepends "Search" to the header
  • Default fallback remains "Documentation" if no header is configured
  • Added comprehensive tests for all scenarios

Considerations

Several approaches were considered:

  1. Keep static text: Simple but inflexible and disconnected from site branding
  2. Direct config usage: Would match branding but could create awkward phrases
  3. Smart dynamic text (chosen): Provides the best balance of branding and readability

The implemented solution:

  • Maintains consistency with site branding
  • Ensures natural language in all cases
  • Handles common "Docs" suffix elegantly
  • Remains fully customizable via configuration
  • Has minimal performance impact
  • Is thoroughly tested

Examples

  • Default: "Search Documentation"
  • Custom: "Search My Project"
  • With Docs: "Search the HydePHP Documentation" (instead of "Search HydePHP Docs")

@emmadesilva emmadesilva marked this pull request as ready for review November 16, 2024 21:58
@codecov
Copy link

codecov bot commented Nov 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (54bb55c) to head (db01c60).
Report is 48 commits behind head on 2.x-dev.

Additional details and impacted files
@@             Coverage Diff             @@
##             2.x-dev     #2032   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity      1891      1891           
===========================================
  Files            194       194           
  Lines           5044      5044           
===========================================
  Hits            5044      5044           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@emmadesilva emmadesilva merged commit c5886eb into 2.x-dev Nov 16, 2024
8 checks passed
@emmadesilva emmadesilva deleted the natural-language-documentation-search-page-title branch November 16, 2024 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants