22 <header class =" navbar" >
33 <SidebarButton @toggle-sidebar =" $emit('toggle-sidebar')" />
44
5- <RouterLink
6- :to =" $localePath"
7- class =" home-link"
8- >
9- <img
10- v-if =" $site.themeConfig.logo"
11- class =" logo"
12- :src =" $withBase($site.themeConfig.logo)"
13- :alt =" $siteTitle"
14- >
15- <span
16- v-if =" $siteTitle"
17- ref =" siteName"
18- class =" site-name"
19- :class =" { 'can-hide': $site.themeConfig.logo }"
20- >{{ $siteTitle }}</span >
5+ <RouterLink :to =" $localePath" class =" home-link" >
6+ <img v-if =" $site.themeConfig.logo" class =" logo" :src =" $withBase($site.themeConfig.logo)" :alt =" $siteTitle" />
7+ <span v-if =" $siteTitle" ref =" siteName" class =" site-name" :class =" { 'can-hide': $site.themeConfig.logo }" >{{ $siteTitle }}</span >
218 </RouterLink >
229
2310 <div
2411 class =" links"
25- :style =" linksWrapMaxWidth ? {
26- 'max-width': linksWrapMaxWidth + 'px'
27- } : {}"
12+ :style ="
13+ linksWrapMaxWidth
14+ ? {
15+ 'max-width': linksWrapMaxWidth + 'px'
16+ }
17+ : {}
18+ "
2819 >
29- <AlgoliaSearchBox
30- v-if =" isAlgoliaSearch"
31- :options =" algolia"
32- />
20+ <AlgoliaSearchBox v-if =" isAlgoliaSearch" :options =" algolia" />
3321 <SearchBox v-else-if =" $site.themeConfig.search !== false && $page.frontmatter.search !== false" />
3422 <NavLinks class =" can-hide" />
3523 </div >
3624 </header >
3725</template >
3826
3927<script >
40- import AlgoliaSearchBox from ' @AlgoliaSearchBox'
41- import SearchBox from ' @SearchBox'
42- import SidebarButton from ' @theme/components/SidebarButton.vue'
43- import NavLinks from ' @theme/components/NavLinks.vue'
28+ import AlgoliaSearchBox from ' @AlgoliaSearchBox' ;
29+ import SearchBox from ' @SearchBox' ;
30+ import SidebarButton from ' @theme/components/SidebarButton.vue' ;
31+ import NavLinks from ' @theme/components/NavLinks.vue' ;
4432
4533export default {
4634 name: ' Navbar' ,
@@ -52,43 +40,42 @@ export default {
5240 AlgoliaSearchBox
5341 },
5442
55- data () {
43+ data () {
5644 return {
5745 linksWrapMaxWidth: null
58- }
46+ };
5947 },
6048
6149 computed: {
62- algolia () {
63- return this .$themeLocaleConfig .algolia || this .$site .themeConfig .algolia || {}
50+ algolia () {
51+ return this .$themeLocaleConfig .algolia || this .$site .themeConfig .algolia || {};
6452 },
6553
66- isAlgoliaSearch () {
67- return this .algolia && this .algolia .apiKey && this .algolia .indexName
54+ isAlgoliaSearch () {
55+ return this .algolia && this .algolia .apiKey && this .algolia .indexName ;
6856 }
6957 },
7058
71- mounted () {
72- const MOBILE_DESKTOP_BREAKPOINT = 719 // refer to config.styl
73- const NAVBAR_VERTICAL_PADDING = parseInt (css (this .$el , ' paddingLeft' )) + parseInt (css (this .$el , ' paddingRight' ))
59+ mounted () {
60+ const MOBILE_DESKTOP_BREAKPOINT = 719 ; // refer to config.styl
61+ const NAVBAR_VERTICAL_PADDING = parseInt (css (this .$el , ' paddingLeft' )) + parseInt (css (this .$el , ' paddingRight' ));
7462 const handleLinksWrapWidth = () => {
7563 if (document .documentElement .clientWidth < MOBILE_DESKTOP_BREAKPOINT ) {
76- this .linksWrapMaxWidth = null
64+ this .linksWrapMaxWidth = null ;
7765 } else {
78- this .linksWrapMaxWidth = this .$el .offsetWidth - NAVBAR_VERTICAL_PADDING
79- - (this .$refs .siteName && this .$refs .siteName .offsetWidth || 0 )
66+ this .linksWrapMaxWidth = this .$el .offsetWidth - NAVBAR_VERTICAL_PADDING - ((this .$refs .siteName && this .$refs .siteName .offsetWidth ) || 0 );
8067 }
81- }
82- handleLinksWrapWidth ()
83- window .addEventListener (' resize' , handleLinksWrapWidth, false )
68+ };
69+ handleLinksWrapWidth ();
70+ window .addEventListener (' resize' , handleLinksWrapWidth, false );
8471 }
85- }
72+ };
8673
87- function css (el , property ) {
74+ function css (el , property ) {
8875 // NOTE: Known bug, will return 'auto' if style value is 'auto'
89- const win = el .ownerDocument .defaultView
76+ const win = el .ownerDocument .defaultView ;
9077 // null means not to return pseudo styles
91- return win .getComputedStyle (el, null )[property]
78+ return win .getComputedStyle (el, null )[property];
9279}
9380 </script >
9481
@@ -114,7 +101,6 @@ $navbar-horizontal-padding = 1.5rem
114101 .links
115102 padding-left 1.5rem
116103 box-sizing border-box
117- background-color white
118104 white-space nowrap
119105 font-size 0.9rem
120106 position absolute
0 commit comments