Skip to content
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

Add/alogliadocs #158

Closed
wants to merge 13 commits into from
Closed

Add/alogliadocs #158

wants to merge 13 commits into from

Conversation

morajabi
Copy link
Member

@morajabi morajabi commented Nov 1, 2017

Fix #85

I've set up the search in the navbar. We are using Algolia docsearhc and the crawler config is live here https://github.com/algolia/docsearch-configs/blob/master/configs/styled-components.json
We can make PRs there to alter it. Also, the styling is the default one and we can customize the look by following the DocSearch documentation:
(https://community.algolia.com/docsearch/documentation/) Which I tried and couldn't change it the way to be better and thought it is unnecessary at this point too, but we can do that at any point.

kitten
kitten previously requested changes Nov 1, 2017
@@ -44,6 +44,7 @@ class DocsLayout extends Component {
title={`styled-components${title ? `: ${title}` : ''}`}
description={description}>
<meta name="robots" content="noodp" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
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 either vendor it into our code or style it manually, I think to keep the requests low. We're already at a high number of requests due to Google

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure! I wanted to do that, but I thought maybe styles are huge to include. So I'll do this with injectGlobal or I should add a style tag inside <Head> by hand?

Copy link
Member

Choose a reason for hiding this comment

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

So, the difference will be small especially on HTTP 2, but this is a small CSS file after all. I can verify what it actually contains and see.

Copy link
Member Author

Choose a reason for hiding this comment

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

btw About Google, we should probably replace that with something else, maybe Heap. Google Analytics is not accurate and also it's so heavy.

Copy link
Member

Choose a reason for hiding this comment

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

We spent months getting GA getting set up correctly, I'm not switching to anything different now. I highly, highly doubt anything else is more accurate.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have proof!

Copy link
Member Author

@morajabi morajabi Nov 9, 2017

Choose a reason for hiding this comment

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

Tim data engineer at Unsplash: https://medium.com/@timmycarbone/google-analytics-modifies-your-data-24d4d6366210

it's only one of the articles that mention this in detail.
GA is also really heavy.

/>
</Wrapper>
)
class Search extends Component {
Copy link
Member

Choose a reason for hiding this comment

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

This should not be in the same file, including the logic above for the import

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point! Thanks

@@ -5,7 +5,7 @@ import rem from '../../utils/rem'
import { navbarHeight } from '../../utils/sizes'
import Link from '../Link'

const Wrapper = styled.nav`
const Wrapper = styled.div`
Copy link
Member

Choose a reason for hiding this comment

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

Was this on purpose?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, we already have a nav for all of the navbar AFAIK. There's no need to nest multiple navs!

@morajabi morajabi dismissed kitten’s stale review November 9, 2017 09:23

Extracted Algolia logic from Search.js and did some refactoring. Also now search only appears on /docs

@mxstbr
Copy link
Member

mxstbr commented Nov 9, 2017

Also now search only appears on /docs

Do we not want people to search from the landing page?

@morajabi
Copy link
Member Author

morajabi commented Nov 9, 2017

@mxstbr We can. I thought Algolia will not respond on the other urls, but it seems it's not true. I'll make it available everywhere and will change the placeholder to Search docs...

UPDATE: Thanks Max for pointing out! Done.

@mxstbr
Copy link
Member

mxstbr commented Nov 10, 2017

Do we have a deploy of this somewhere?

@morajabi
Copy link
Member Author

morajabi commented Nov 10, 2017

@mxstbr No... until now 😉 https://styled-components-docs-dmtxaiqtba.now.sh

@mxstbr
Copy link
Member

mxstbr commented Nov 10, 2017

That looks great! 😍 I'm not seeing a search in the navbar on the docs pages though?

@morajabi
Copy link
Member Author

@mxstbr That's thanks to the awesome Algoliadocs! (we can customize the styling easily though if we wanted to)

Are you sure it's not cached or something?
screen shot 2017-11-10 at 2 56 15 pm

@mxstbr
Copy link
Member

mxstbr commented Nov 10, 2017

Oh yeah now it's loaded, weird.

@morajabi
Copy link
Member Author

And this? :)

componentDidMount() {
if (process.browser && typeof docsearch !== 'undefined') {
docsearch({
apiKey: '79886fb59ad3ebe2002b481cffbbe7cb',
Copy link
Member

Choose a reason for hiding this comment

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

Is this safe to be committed?

Copy link
Member Author

Choose a reason for hiding this comment

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

dunno, but I suppose you can see the email they've sent me in the issue. They clearly said use it in the client side.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah if it's client-side it has to be safe to commit.

}

componentDidMount() {
if (process.browser && typeof docsearch !== 'undefined') {
Copy link
Member

Choose a reason for hiding this comment

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

Let's require docsearch down here instead and remove the process.browser stuff since componentDidMount doesn't run on the server

isDocs = true

componentWillMount() {
this.isDocs = process.browser && Router.pathname.startsWith('/docs')
Copy link
Member

Choose a reason for hiding this comment

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

I don't see why this should have process.browser? Isn't the router universal?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it's not.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, then that's fine 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

but it supposed to be.

kitten
kitten previously approved these changes Nov 13, 2017
@mxstbr
Copy link
Member

mxstbr commented Nov 13, 2017

I can't wait to land this 😍 Such an important enhancement!

@mxstbr
Copy link
Member

mxstbr commented Dec 18, 2017

Ugh why haven't we shipped this yet?! @morajabi mind resolving the conflicts? Then I'll go ahead, merge and ship this.

@morajabi
Copy link
Member Author

I deleted yarn.lock and regenerated it.

@mxstbr
Copy link
Member

mxstbr commented Dec 19, 2017

Ugh even more conflicts. 🙄 I suck at this, mind merging master in again? That should fix the tests then we can finally ship this!

@morajabi
Copy link
Member Author

morajabi commented Dec 19, 2017

Why my PRs are always like this 😄 It's all on @philpl 😈💩

@mxstbr
Copy link
Member

mxstbr commented Dec 19, 2017

Haha I'm so sorry, I should've shipped this first! 🙈 My bad!

@morajabi
Copy link
Member Author

morajabi commented Dec 19, 2017

@mxstbr I'm almost always joking haha isn't it visible from tons of emojis I use?!?!?!

@Haroenv
Copy link

Haroenv commented Jan 5, 2018

Any help needed getting this merged?

@morajabi
Copy link
Member Author

morajabi commented Jan 5, 2018

@Haroenv Thank you, Haroen, I forgot to rebase this, lemme try again.

@quantizor
Copy link
Contributor

@morajabi looks like this needs a lot of rebasing

@imbhargav5
Copy link
Member

@morajabi I think we should start integrating DocSearch again. I requested new keys from Algolia. Can I fix this in a different PR?

@quantizor quantizor closed this Sep 30, 2018
@quantizor quantizor deleted the add/alogliadocs branch September 30, 2018 22:21
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.

None yet

6 participants