8000 Enable page heading searchable via `SearchIndexPlugin` · Issue #660 · jpmorganchase/mosaic · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
< 8000 div data-target="react-app.reactRoot">
Enable page heading searchable via SearchIndexPlugin #660
Open
@origami-z

Description

@origami-z

Currently the plugin produces a search index with all content on a page as string for a route.

type SearchDataPage = {
title: string;
content: string[];
route: string;
};

This doesn't allow the use case to search for specific page section heading and navigate to it.

Potential solution - it may mean a similar data like below

type SearchDataPage = {
  title: string;
  sections: {
    heading?: string;
    id?: string;
    content: string[];
  }[];
  route: string;
};

This likely means 2 different parts of change, first when indexing content, it will need to differentiate heading (e.g. AST type: "element" andtagName: "h1") vs other content

visit(
tree,
(node: Node) => node.type === 'text' || node.type === 'code',
(node: LeafNode) => {
const segments = [...segmenter.segment(node.value)].map(segment => segment.segment);
segments.forEach(segment => {
if (maxLineLength) {
sentences.push(segment.slice(0, maxLineLength));
} else {
sentences.push(segment);
}
});
}
);

I'm not sure how to deal with getting correct id, given computing id from heading is not enough given potential collision. This could mean a different lifecycle method is needed for this to work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0