conwnet / github1s

One second to read GitHub code with VS Code.
https://github1s.com
MIT License
22.89k stars 871 forks source link

Add a route that can be searched directly with parameters #428

Closed theowenyoung closed 2 years ago

theowenyoung commented 2 years ago

Hi, this is an amazing project, I want to use it as my blog's global search, is it a use case?

Now I can manually enter https://github1s.com/theowenyoung/blog, and click the search button to search the files, but it's really helped if there is a direct route to navigate the search panel. something like:

https://github1s.com/theowenyoung/blog/panel/search?q=term&files-include=content

does it possible? or if can, I can try to submit a pr.

welcome[bot] commented 2 years ago

Hello there!πŸ‘‹ Welcome to the project!πŸ’– Thank you and congratsπŸŽ‰for opening your very first issue in this project.Be patient while we get back to you.πŸ˜„

github-actions[bot] commented 2 years ago

Hello there theowenyoung πŸ‘‹

Welcome to github1s !!πŸ’–πŸ₯³

Thank you and congratulations πŸŽ‰ for opening your very first issue in this project. github1s fosters an open and welcoming environment for all our contributors.🌸

Incase you want to claim this issue, please comment down below! We will try to get back to you as soon as we can.πŸ‘€

Feel free to visit github1s.com. πŸ‘©β€πŸ’» If you have any interesting ideas, just open an issue. We would love to hear you and engage in discussions.

Siddhant-K-code commented 2 years ago

For Search, we use Sourcegraph GraphQL APIs. Which hits the endpoint: https://sourcegraph.com/.api/graphql with payload:

{
  "variables": {
    "query": "repo:^github\\.com/theowenyoung/blog$ file:content -file:\\.git|\\.svn|\\.hg|CVS|\\.DS_Store|Thumbs.db|\\.crswap|node_modules|bower_components|\\.code-search \"term\" count:30"
  },
  "query": "query ($query: String!) {\n  search(query: $query) {\n    results {\n      __typename\n      limitHit\n      matchCount\n      approximateResultCount\n      missing {\n        name\n        __typename\n      }\n      cloning {\n        name\n        __typename\n      }\n      timedout {\n        name\n        __typename\n      }\n      indexUnavailable\n      results {\n        ... on FileMatch {\n          __typename\n          file {\n            name\n            path\n            __typename\n          }\n          lineMatches {\n            preview\n            lineNumber\n            offsetAndLengths\n            __typename\n          }\n        }\n        __typename\n      }\n    }\n    __typename\n  }\n}"
}

I am not 100% sure that is possible. But there should be some workaround for that.

WDYT? @conwnet @xcv58

xcv58 commented 2 years ago

I think it's doable but we need to refactor the code to sync the search state with URL.

conwnet commented 2 years ago

yes, and I think this is reasonable, let me support it at next version