Skip to content

Implement search page #1488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 2, 2018
Merged

Implement search page #1488

merged 6 commits into from
May 2, 2018

Conversation

NoelDeMartin
Copy link
Contributor

Implementation for issue #1087. The url would be https://vuejs.org/v2/search/?q={{search query}}.

I have never worked with algolia nor hexo before, so please check that I didn't miss anything. I think the styles could also be improved. And I tried to follow the coding style the best I could (like not using semicolon), but I may have missed something.

In any case, I'll be happy to fix anything that you consider so please let me know what you think :D.

@chrisvfritz
Copy link
Contributor

@phanan Would you mind reviewing this? I think this review requires more design expertise and that's definitely an area where you excel far beyond me. 😄

@phanan phanan self-requested a review March 17, 2018 06:44
Copy link
Member

@phanan phanan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NoelDeMartin very nice implementation, thanks! I have a couple of question though:

  • Is it meant to be an orphan page? I see no link to get to the page (I'm not familiar with how DuckDuckGo works FWIW)
  • Can/should we update the URL with every search input change? Right now they're out of sync.
  • Is there a reason why menu and sponsor info are hidden from the page?

<input
class="search-query"
v-model="search"
placeholder="Search VueJS"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest just "Search" or "Search Vue.js" here.


</div>

<script src="//cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should always be https:// regardless of the original site protocol.

var version = match ? match[1] : 'v2'
var algolia = algoliasearch('BH4D9OD16A', '85cc3221c9f23bfbaa4e3913dd7625ea')
var algoliaHelper = algoliasearchHelper(algolia, 'vuejs', {
hitsPerPage: 15,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use 2-space indentation (both JS and HTML) for our docs, can you please check?

},
methods: {
addPage() {
algoliaHelper.setCurrentPage(this.lastPage+1).search()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space around +

@NoelDeMartin
Copy link
Contributor Author

Ok I have applied the changes you mentioned, to answer your questions:

  • DuckDuckGo is a search engine with a feature called "bangs", which allows you to search directly in other websites, and since it can be configured as a default search engine for the browser, makes it very easy to search for documentation. What we want to achieve is that you would write something like "v-model !vue" in your navigation bar and it would take you directly to this search results page, without needing to visit the search engine. More info about that here: https://duckduckgo.com/bang. About this being an orphan page, I see some value here regardless of using duck duck go or not, because you can get more results in this page (it's implemented with infinite scroll), I don't know how easy it would be to add a "show more results" button on the instant search on top linking to this page. If you think it makes sense I could look into implementing that as well.
  • I based my implementation on this: https://symfony.com/search and it behaves as you say. Personally I don't like it because it clutters browsing history and back arrow behaviour. But I guess it's a personal preference, so I don't know, whatever you prefer.
  • I don't know which menu should be here, since this searches everywhere (Guide, API, etc.). Sponsor info I'm not sure where to find it in other pages (other than the ones dedicated to that), if you tell me where to find an example I could add it.

And about the https links, I did it like the search on the top is implemented now, so maybe you want to update it as well:

<!-- search -->
<link href="//cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css" rel='stylesheet' type='text/css'>
<%- css('css/search') %>
<script src="//cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script>

@phanan
Copy link
Member

phanan commented Mar 18, 2018

  • @chrisvfritz what do you think about the page being orphan? I don't have a background about this, so I can't tell
  • Re: URL, IMO it should behave like the Symfony one
  • The sponsor info is in partials/sponsors_sidebar.ejs, which is included in sidebar.ejs, which in turn is automatically included if your index.md has a type attribute. Simply adding an arbitrary type won't work that well though, as such will render the whole menu tree to the left as well (which you don't want), so you'll need to play around a bit with the logic.

@chrisvfritz
Copy link
Contributor

I think it being an orphan is fine. If people want to search while already on the site, there's already a search bar available at the top, so people might only use a dedicated search page when being directed from other services like DuckDuckGo.

@NoelDeMartin
Copy link
Contributor Author

Ok I have added the push history behaviour and sponsors information. I have adblock installed and seems like sponsors are treated as ads, because I wasn't seeing them anywhere. That explains why I couldn't see them anywhere other than the sponsors page.

@phanan
Copy link
Member

phanan commented Mar 19, 2018 via email

@NoelDeMartin
Copy link
Contributor Author

Yeah of course, I already did, I didn't think about it before but now that I noticed I have it whitelisted.

@phanan
Copy link
Member

phanan commented Mar 19, 2018

LGTM now, thanks a lot! If we could have arrow-key navigation for the results, it would be even better, but I believe this is good enough for now.

& + .breadcrumb::before
content: "\203A\A0"
margin-left: 5px
color: $light
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, we need an EOL here btw.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 👍

@NoelDeMartin
Copy link
Contributor Author

Cool, thanks :D. Yeah I think arrow navigation and adding a "view more results" link in top bar search would be good improvements in the future.

@dear-lizhihua
Copy link
Contributor

nice page!

@chrisvfritz
Copy link
Contributor

One quick note: if I press Enter in the search input, it currently refreshes the page and clears the search. Could we instead have it match the behavior of the top search bar, where Enter takes you to the first result?

@NoelDeMartin
Copy link
Contributor Author

@chrisvfritz Yeah that's a good idea, and easy to implement. You can test in on the last commit.

@chrisvfritz
Copy link
Contributor

Fantastic! A few other notes:

  • I noticed that this page uses a layout that assumes a sidebar, making it look a little strange at many screen widths because it's not quite centered. We might not need to use a completely different layout to fix this though. We have a media query to fall back to a centered layout (I think at 900px), so we could possibly use those styles for every screen width for this page.
  • Perhaps a nitpick, but "Search Vue.js" sounds a little ambiguous to me, like it might be searching the source code rather than this site. Maybe we should change it to just "Search" or "Search this site"?

@Akryum
Copy link
Member

Akryum commented Mar 19, 2018

Copy link
Member

@Akryum Akryum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The page is missing the 'search by Algolia' logo which is mandatory.

@NoelDeMartin
Copy link
Contributor Author

@chrisvfritz Yeah, the sidebar layout looks weird, but I needed to add it because the sponsors section is located inside of the sidebar. The thing is that it has a fixed position, so it could technically be outside of the sidebar, but on mobile it is inside of the menu so I'm not sure how to go about it, I guess someone who's worked more with the site can have a better opinion. I also removed what appears by default in the sidebar, because it was a menu with only one section so I thought it'd be better to show nothing instead.

I can change the text on the search box once it's decided 100%, because I already changed it once. I still vote for using "Search VueJS" which was my initial proposal, but I don't mind which one you want to put either way.

@Akryum I didn't know it was mandatory, I'll do it in then.

Copy link
Contributor Author

@NoelDeMartin NoelDeMartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added "search by algolia". In the symfony page seems like they have a custom url for that: https://www.algolia.com/cc/symfony?hi=symfony&utm_source=symfony&utm_medium=link&utm_campaign=symfony_search but I couldn't find one for vue so I left algolia homepage for now.

& + .breadcrumb::before
content: "\203A\A0"
margin-left: 5px
color: $light
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 👍

@NoelDeMartin
Copy link
Contributor Author

@chrisvfritz Is there anything else needed for this to be merged?

@chrisvfritz
Copy link
Contributor

Nope, thanks for the ping. This just fell off my radar. 🙂

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.

5 participants