Skip to content

Event search index descriptions incorrectly end with "undefined" #1512

Description

@slash-init

Most appropriate sections of the p5.js website?

Community (Sketches, Libraries, Events)

What is your operating system?

Linux

Web browser and version

Firefox 152.0.4

Actual Behavior

The generated search index appends the literal string "undefined" to the end of every event description across all generated locale search indices (en.json, es.json, hi.json, ko.json, and zh-Hans.json).
This is caused by concatenating content + data.description in src/scripts/builders/search.ts. Event pages do not define a description field, so data.description is undefined, which JavaScript coerces into the literal string "undefined" during string concatenation.
As a result, every generated search index contains incorrect event descriptions.

Expected Behavior

Generated event descriptions should not include the literal string "undefined".

Steps to reproduce

  1. Generate the search index:

    npm run build:search
  2. Start the development server:

    npm run dev
  3. Open the browser DevTools Console and run:

    fetch("/search-indices/en.json")
      .then(r => r.json())
      .then(data => {
        const events = Object.values(data.events);
    
        console.log("Total events:", events.length);
        console.log(
          "Ends with 'undefined':",
          events.filter(event => event.description.endsWith("undefined")).length
        );
      });
  4. Observe the output:

    Total events: 5
    Ends with 'undefined': 5
    

Alternatively, inspect any of the generated search index files (en.json, es.json, hi.json, ko.json, or zh-Hans.json) and search for:

undefined"

Every event description ends with the literal string "undefined".

Would you like to work on the issue?

Yes

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions