diff --git a/src/components/Search/SearchClient.jsx b/src/components/Search/SearchClient.jsx index 70ee378b..4addc346 100644 --- a/src/components/Search/SearchClient.jsx +++ b/src/components/Search/SearchClient.jsx @@ -128,10 +128,7 @@ SearchClient.propTypes = { const ResultList = ({ searchResults }) => { return (
-
- Total results found: {searchResults.length} [Searched from Tutorials and - Core Concepts] -
+
Total results found: {searchResults.length}
diff --git a/src/components/Search/SearchComponent.jsx b/src/components/Search/SearchComponent.jsx index 2ba9531e..696fbce3 100644 --- a/src/components/Search/SearchComponent.jsx +++ b/src/components/Search/SearchComponent.jsx @@ -10,7 +10,9 @@ import PropTypes from 'prop-types' const SearchComponent = ({ location }) => { const data = useStaticQuery(graphql` query { - allMarkdownRemark(filter: { fileAbsolutePath: { regex: "/content/" } }) { + allMarkdownRemark( + filter: { fileAbsolutePath: { regex: "/content/|/markdowns/" } } + ) { edges { node { fields { @@ -20,6 +22,9 @@ const SearchComponent = ({ location }) => { frontmatter { title description + app + slug + module } id plainText @@ -28,20 +33,33 @@ const SearchComponent = ({ location }) => { } } `) + const searchableData = data.allMarkdownRemark.edges.map(({ node }) => { - var section = 'Concepts' - if (node.fields.slug.startsWith('/tutorials')) section = 'Tutorials' + var { slug } = node.fields + var section = null + + if (node.fields.slug.startsWith('/tutorials')) { + section = 'Tutorials' + } else if (node.fields.slug.startsWith('/concepts')) { + section = 'Core concepts' + } else if (node.frontmatter.module) { + // This is for adding py module docs to index + slug = `/references/read-the-docs/${node.frontmatter.app.replace( + '.', + '-' + )}/${node.frontmatter.slug}` + section = `API References [${node.frontmatter.app}]` + } return { title: node.frontmatter.title, description: node.frontmatter.description, - slug: node.fields.slug, id: node.id, text: node.plainText, - section: section + slug, + section } }) - return (