Skip to content

Restructure generated site data for searchbar ui#1006

Merged
yamgent merged 1 commit into
MarkBind:masterfrom
ang-zeyu:searchbar-ui-organization
Feb 15, 2020
Merged

Restructure generated site data for searchbar ui#1006
yamgent merged 1 commit into
MarkBind:masterfrom
ang-zeyu:searchbar-ui-organization

Conversation

@ang-zeyu

@ang-zeyu ang-zeyu commented Jan 31, 2020

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [x] Enhancement to an existing feature

Resolves #994
Requires MarkBind/vue-strap#126 ( searchbar ui for vue-strap )

What is the rationale for this request?
Generated site data for the searchbar needs to be restructured to sift out the keywords from the heading deterministically.

What changes did you make? (Give an overview)
Generated site data:

  • headings now store only the id:'heading text...' pair instead of id:'heading text... | concatenated keywords ...'
  • keywords for headings are now stored in the headingKeywords field
  • Removed concatenateHeadingsAndKeywords which is no longer needed

Provide some example code that this change will affect:

New site data:

const siteData = {
    enableSearch: this.siteConfig.enableSearch,
    pages: this.pages.filter(page => page.searchable)
      .map(page => ({
        ...page.frontMatter,
        headings: page.headings,
        headingKeywords: page.keywords,
      })),
  };

Is there anything you'd like reviewers to focus on?
na

Testing instructions:
npm run test should pass

Proposed commit message: (wrap lines at 72 characters)

Restructure generated site data for searchbar ui

Keywords tied to a heading are appended to the heading with a prepending
'|' character.
This is so that the '|' character would serve as a visual separator
between the heading and the keyword.

However, it is thus not possible to extract a keyword from its heading
deterministically, as a heading can also include the '|' character.

Let's move the keywords to its own field, allowing the searchbar to
extract a heading's keyword from it.

@ang-zeyu

ang-zeyu commented Feb 5, 2020

Copy link
Copy Markdown
Contributor Author

Rebased on latest, no conflicts

Keywords tied to a heading are appended to the heading with a prepending
'|' character.
This is so that the '|' character would serve as a visual separator
between the heading and the keyword.

However, it is thus not possible to extract a keyword from its heading
deterministically, as a heading can also include the '|' character.

Let's move the keywords to its own field, allowing the searchbar to
extract a heading's keyword from it.
@ang-zeyu ang-zeyu force-pushed the searchbar-ui-organization branch from c2f3d64 to b714c19 Compare February 11, 2020 11:00
@ang-zeyu

Copy link
Copy Markdown
Contributor Author

Rebased on the latest master, no conflicts / changes otherwise

@yamgent yamgent merged commit 0dde42d into MarkBind:master Feb 15, 2020
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.

Improve default search UI organization

3 participants