vuepress-theme-uniapp-official 1.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/components/AlgoliaSearchBox.vue +130 -0
- package/components/DcloudSearchPage/components/Result.vue +160 -0
- package/components/DcloudSearchPage/components/Results.vue +66 -0
- package/components/DcloudSearchPage/components/pagination.vue +155 -0
- package/components/DcloudSearchPage/index.styl +183 -0
- package/components/DcloudSearchPage/index.vue +500 -0
- package/components/DcloudSearchPage/styles/ask.styl +272 -0
- package/components/DcloudSearchPage/styles/ext.styl +68 -0
- package/components/DcloudSearchPage/utils/Base64.js +134 -0
- package/components/DcloudSearchPage/utils/mock.js +434 -0
- package/components/DcloudSearchPage/utils/postDcloudServer.js +141 -0
- package/components/DcloudSearchPage/utils/searchClient.js +101 -0
- package/components/DcloudSearchPage/utils/searchUtils.js +52 -0
- package/components/Footer.vue +142 -0
- package/components/MainNavbarLink.vue +57 -0
- package/components/NavLink.vue +95 -0
- package/components/NavLinks.vue +173 -0
- package/components/Navbar.vue +322 -0
- package/components/NavbarLogo.vue +24 -0
- package/components/OutboundLink.vue +45 -0
- package/components/SearchBox/dist/match-query.dev.js +61 -0
- package/components/SearchBox/index.vue +337 -0
- package/components/SearchBox/match-query.js +51 -0
- package/components/SearchBox/search.svg +1 -0
- package/components/SidebarGroup.vue +141 -0
- package/components/SidebarLink.vue +152 -0
- package/components/SidebarLinks.vue +106 -0
- package/components/SiderBarBottom.vue +134 -0
- package/components/Sticker.vue +64 -0
- package/components/Toc-top.vue +95 -0
- package/components/Toc.vue +165 -0
- package/config/copy.js +7 -0
- package/config/footer.js +195 -0
- package/config/i18n/index.js +2 -0
- package/config/navbar.js +163 -0
- package/config/redirectRouter.js +120 -0
- package/config/searchPage.js +48 -0
- package/config/siderbar/index.js +8 -0
- package/config/siderbar/uni-app.js +210 -0
- package/config/siderbar/uniCloud.js +55 -0
- package/config/toc.js +5 -0
- package/enhanceApp.js +142 -0
- package/global-components/CodeSimulator.vue +211 -0
- package/global-components/icons.js +647 -0
- package/global-components/iconsLayouts.vue +117 -0
- package/global-components/uniIcon.vue +85 -0
- package/global-components/uniicons.css +656 -0
- package/global-components/uniicons.ttf +0 -0
- package/index.js +152 -0
- package/layouts/404.vue +22 -0
- package/layouts/Layout.vue +238 -0
- package/layouts/SimpleLayout.vue +18 -0
- package/mixin/navInject.js +21 -0
- package/mixin/navProvider.js +65 -0
- package/mixin/toc.js +36 -0
- package/package.json +50 -0
- package/styles/custom-block.styl +336 -0
- package/styles/footer.styl +248 -0
- package/styles/index.styl +197 -0
- package/styles/navbar.styl +293 -0
- package/styles/palette.styl +9 -0
- package/util/index.js +317 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<header class="navbar" :class="{ 'navbar-fixed': fixedNavbar }">
|
|
3
|
+
<div class="main-navbar">
|
|
4
|
+
<!-- <SidebarButton @toggle-sidebar="$emit('toggle-sidebar')" /> -->
|
|
5
|
+
|
|
6
|
+
<NavbarLogo />
|
|
7
|
+
|
|
8
|
+
<div class="main-navbar-links can-hide">
|
|
9
|
+
<template v-for="(item, index) in customNavBar">
|
|
10
|
+
<div :class="mainNavLinkClass(index)" :key="item.text">
|
|
11
|
+
<MainNavbarLink v-if="item.type" :item='item' />
|
|
12
|
+
<a v-else href="javascript:;" @click="changeUserNav(index)">{{item.text}}</a>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<div class="mobile-main-navbar">
|
|
18
|
+
<div class="mobile-links_mobile">
|
|
19
|
+
<a href="javascript:;" class="mobile-links__btn" @click="toggleMobilePanel">{{mainNavBarText}}</a>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="mobile-links__panel" :class="{open: showMobilePanel}">
|
|
22
|
+
<template v-for="(item, index) in customNavBar">
|
|
23
|
+
<div :class="mainNavLinkClass(index)" :key="item.text">
|
|
24
|
+
<MainNavbarLink v-if="item.type" :item='item' @click.native="toggleMobilePanel" />
|
|
25
|
+
<a v-else href="javascript:;" @click="changeUserNav(index),toggleMobilePanel()">{{item.text}}</a>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div class="dropdown-language" @click="switchLanguage">
|
|
32
|
+
<div style="display: flex;align-items: center;">
|
|
33
|
+
<span>{{navbarLanguage[navConfig.languageIndex].text}}</span>
|
|
34
|
+
<svg t="1629441415944" viewBox="0 20 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3713"
|
|
35
|
+
width="16" height="16" class="icon">
|
|
36
|
+
<path
|
|
37
|
+
d="M508.025406 655.446718c-14.45307 0-28.183486-5.781228-39.023289-15.898376l-231.249118-231.249118c-10.117149-10.117149-10.117149-26.015526 0-36.132675s26.015526-10.117149 36.132675 0l231.249118 231.249118c2.16796 2.16796 4.335921 2.16796 5.781228 0l231.971771-231.971771c10.117149-10.117149 26.015526-10.117149 35.410021 0 10.117149 10.117149 10.117149 26.015526 0 36.132674l-231.971771 231.971772c-9.394495 10.117149-23.124912 15.898377-38.300635 15.898376z"
|
|
38
|
+
p-id="3714"></path>
|
|
39
|
+
</svg>
|
|
40
|
+
</div>
|
|
41
|
+
<div v-if="showLanguage" class="dropdown-content">
|
|
42
|
+
<div
|
|
43
|
+
v-for="(item,index) in navbarLanguage"
|
|
44
|
+
:key="item.link"
|
|
45
|
+
@click="() => { typeof item.click === 'function' && item.click(index === navConfig.languageIndex) }"
|
|
46
|
+
>
|
|
47
|
+
<a :href="index === navConfig.languageIndex ? 'javascript:;' : item.link" target="_self" :key="item.text"
|
|
48
|
+
:class="[index === navConfig.languageIndex ? 'clickDisabled' : '']">
|
|
49
|
+
{{item.text}}
|
|
50
|
+
</a>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div class="links" :style="SearchBoxStyle">
|
|
56
|
+
<!-- <a class="switch-version" href="javascript:void(0)">回到旧版</a> -->
|
|
57
|
+
<DcloudSearchPage v-if="isAlgoliaSearch" ref="dcloudSearchPage" :options="algolia" />
|
|
58
|
+
<AlgoliaSearchBox v-if="isAlgoliaSearch" />
|
|
59
|
+
<SearchBox v-else-if="$site.themeConfig.search !== false && $page.frontmatter.search !== false" />
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<div class="sub-navbar">
|
|
64
|
+
<DropdownLink class="custom-main-navbar can-hide" v-if="showSubNavBar && fixedNavbar" :item="{
|
|
65
|
+
text: customNavBarKeys[navConfig.userNavIndex],
|
|
66
|
+
items: customNavBar
|
|
67
|
+
}" />
|
|
68
|
+
<NavLinks class="can-hide" />
|
|
69
|
+
<div class="mobile-sub-navbar">
|
|
70
|
+
<div class="subnavbar__item" @click="$emit('toggle-sidebar')">
|
|
71
|
+
<a href="javascript:;">{{subNavBarText}}</a>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</header>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<script>
|
|
79
|
+
import AlgoliaSearchBox from './AlgoliaSearchBox'
|
|
80
|
+
import SearchBox from './SearchBox'
|
|
81
|
+
import SidebarButton from '@theme/components/SidebarButton.vue'
|
|
82
|
+
import NavLinks from '@theme/components/NavLinks.vue'
|
|
83
|
+
import MainNavbarLink from './MainNavbarLink.vue';
|
|
84
|
+
import NavbarLogo from './NavbarLogo.vue';
|
|
85
|
+
import DcloudSearchPage from './DcloudSearchPage';
|
|
86
|
+
import navInject from '../mixin/navInject';
|
|
87
|
+
import DropdownLink from '@theme/components/DropdownLink.vue'
|
|
88
|
+
import { forbidScroll, os } from '../util';
|
|
89
|
+
|
|
90
|
+
export default {
|
|
91
|
+
name: 'Navbar',
|
|
92
|
+
|
|
93
|
+
mixins: [ navInject ],
|
|
94
|
+
|
|
95
|
+
components: {
|
|
96
|
+
SidebarButton,
|
|
97
|
+
NavLinks,
|
|
98
|
+
MainNavbarLink,
|
|
99
|
+
SearchBox,
|
|
100
|
+
AlgoliaSearchBox,
|
|
101
|
+
NavbarLogo,
|
|
102
|
+
DcloudSearchPage,
|
|
103
|
+
DropdownLink
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
data () {
|
|
107
|
+
return {
|
|
108
|
+
linksWrapMaxWidth: null,
|
|
109
|
+
showMobilePanel: false,
|
|
110
|
+
fixedNavbar: false,
|
|
111
|
+
SearchBoxTop: 0,
|
|
112
|
+
showLanguage: false
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
computed: {
|
|
117
|
+
algolia () {
|
|
118
|
+
return this.$themeLocaleConfig.algolia || this.$site.themeConfig.algolia || {}
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
isAlgoliaSearch () {
|
|
122
|
+
return this.algolia && this.algolia.apiKey && this.algolia.indexName
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
SearchBoxStyle () {
|
|
126
|
+
const initStyle = {
|
|
127
|
+
top: `${this.SearchBoxTop}px`,
|
|
128
|
+
zIndex: 100
|
|
129
|
+
};
|
|
130
|
+
return this.linksWrapMaxWidth
|
|
131
|
+
? Object.assign({}, initStyle, {
|
|
132
|
+
'max-width': this.linksWrapMaxWidth + 'px',
|
|
133
|
+
})
|
|
134
|
+
: initStyle;
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
languageBoxStyle () {
|
|
138
|
+
return {right:(this.linksWrapMaxWidth + 10) + 'px'}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
mounted () {
|
|
143
|
+
const MOBILE_DESKTOP_BREAKPOINT = 719 // refer to config.styl
|
|
144
|
+
const NAVBAR_VERTICAL_PADDING = parseInt(css(this.$el, 'paddingLeft')) + parseInt(css(this.$el, 'paddingRight'))
|
|
145
|
+
const handleLinksWrapWidth = () => {
|
|
146
|
+
if (document.documentElement.clientWidth < MOBILE_DESKTOP_BREAKPOINT) {
|
|
147
|
+
this.linksWrapMaxWidth = null
|
|
148
|
+
} else {
|
|
149
|
+
this.linksWrapMaxWidth = this.$el.offsetWidth - NAVBAR_VERTICAL_PADDING
|
|
150
|
+
- (this.$refs.siteName && this.$refs.siteName.offsetWidth || 0)
|
|
151
|
+
}
|
|
152
|
+
this.$nextTick(this.initNavBar)
|
|
153
|
+
}
|
|
154
|
+
handleLinksWrapWidth()
|
|
155
|
+
window.addEventListener('resize', handleLinksWrapWidth, false)
|
|
156
|
+
window.addEventListener('click',(e)=> {
|
|
157
|
+
this.showLanguage = false
|
|
158
|
+
})
|
|
159
|
+
this.initNavBar()
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
methods: {
|
|
163
|
+
initNavBar () {
|
|
164
|
+
os.init()
|
|
165
|
+
this.sideBar = document.querySelector('.sidebar')
|
|
166
|
+
this.navbar = document.querySelector('.navbar')
|
|
167
|
+
this.mainNavBar = document.querySelector('.main-navbar')
|
|
168
|
+
this.subNavBar = document.querySelector('.sub-navbar')
|
|
169
|
+
this.pageContainer = document.querySelector('.page')
|
|
170
|
+
this.vuepressToc = document.querySelector('.vuepress-toc')
|
|
171
|
+
this.navbarHeight = this.navbar.clientHeight
|
|
172
|
+
this.subNavBarHeight = this.subNavBar.clientHeight
|
|
173
|
+
this.mainNavBarHeight = this.mainNavBar.clientHeight
|
|
174
|
+
this.scrollBehavior()
|
|
175
|
+
},
|
|
176
|
+
scrollBehavior () {
|
|
177
|
+
this.removeWindowScroll()
|
|
178
|
+
this.onWindowScroll()
|
|
179
|
+
if(this.showSubNavBar) {
|
|
180
|
+
this.addWindowScroll()
|
|
181
|
+
} else {
|
|
182
|
+
this.fixedNavbar = true
|
|
183
|
+
this.SearchBoxTop = 0
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
addWindowScroll () {
|
|
187
|
+
if (os.pc) {
|
|
188
|
+
window.addEventListener('scroll', this.onWindowScroll, false)
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
removeWindowScroll () {
|
|
192
|
+
window.removeEventListener('scroll', this.onWindowScroll)
|
|
193
|
+
this.fixedNavbar = false
|
|
194
|
+
this.sideBar && this.sideBar.removeAttribute('style')
|
|
195
|
+
this.vuepressToc && this.vuepressToc.removeAttribute('style')
|
|
196
|
+
this.navbar && this.navbar.removeAttribute('style')
|
|
197
|
+
if (this.pageContainer) {
|
|
198
|
+
this.pageContainer.style.marginTop = this.showSubNavBar || !os.pc ? 'auto' : `${this.navbarHeight}px`
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
onWindowScroll () {
|
|
202
|
+
const scrollTop = !this.showSubNavBar ? 0 : document.documentElement.scrollTop || document.body.scrollTop;
|
|
203
|
+
|
|
204
|
+
if (!this.fixedNavbar) {
|
|
205
|
+
let sideTop = this.navbarHeight - scrollTop
|
|
206
|
+
sideTop <= this.subNavBarHeight && (sideTop = this.subNavBarHeight)
|
|
207
|
+
this.sideBar && (this.sideBar.style.top = `${sideTop + 1}px`)
|
|
208
|
+
this.vuepressToc && (this.vuepressToc.style.top = `${sideTop + 1}px`)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (scrollTop >= this.mainNavBarHeight) {
|
|
212
|
+
if (!this.fixedNavbar) {
|
|
213
|
+
this.fixedNavbar = true
|
|
214
|
+
this.navbar.style.top = `-${this.mainNavBarHeight}px`
|
|
215
|
+
this.SearchBoxTop = this.mainNavBarHeight + (this.subNavBarHeight - this.mainNavBarHeight) / 2
|
|
216
|
+
this.$nextTick(() => {
|
|
217
|
+
this.pageContainer && (this.pageContainer.style.marginTop = `${this.navbarHeight}px`)
|
|
218
|
+
})
|
|
219
|
+
}
|
|
220
|
+
} else if (scrollTop < this.mainNavBarHeight) {
|
|
221
|
+
if (this.fixedNavbar) {
|
|
222
|
+
this.fixedNavbar = false
|
|
223
|
+
this.pageContainer && (this.pageContainer.style.marginTop = 'auto')
|
|
224
|
+
this.SearchBoxTop = 0
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
fixedSideBarHeight () {
|
|
229
|
+
if(!os.pc) return
|
|
230
|
+
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
|
|
231
|
+
this.navbarHeight = this.navbar.clientHeight
|
|
232
|
+
this.subNavBarHeight = this.subNavBar.clientHeight
|
|
233
|
+
const setHeight = !!scrollTop || this.fixedNavbar ? this.subNavBarHeight : this.navbarHeight
|
|
234
|
+
this.sideBar.style.top = `${setHeight + 1}px`
|
|
235
|
+
this.vuepressToc.style.top = `${setHeight + 1}px`
|
|
236
|
+
},
|
|
237
|
+
mainNavLinkClass (index) {
|
|
238
|
+
return ['main-navbar-item', this.navConfig.userNavIndex === index ? 'active' : '']
|
|
239
|
+
},
|
|
240
|
+
toggleMobilePanel () {
|
|
241
|
+
this.showMobilePanel = !this.showMobilePanel
|
|
242
|
+
forbidScroll(this.showMobilePanel)
|
|
243
|
+
},
|
|
244
|
+
switchLanguage (e) {
|
|
245
|
+
e.stopPropagation()
|
|
246
|
+
this.showLanguage = !this.showLanguage
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
|
|
250
|
+
watch: {
|
|
251
|
+
fixedNavbar () {
|
|
252
|
+
this.fixedSideBarHeight()
|
|
253
|
+
this.scrollBehavior()
|
|
254
|
+
},
|
|
255
|
+
'navConfig.userNavIndex' () {
|
|
256
|
+
this.$nextTick(()=>{
|
|
257
|
+
this.fixedSideBarHeight()
|
|
258
|
+
this.scrollBehavior()
|
|
259
|
+
})
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function css (el, property) {
|
|
265
|
+
// NOTE: Known bug, will return 'auto' if style value is 'auto'
|
|
266
|
+
const win = el.ownerDocument.defaultView
|
|
267
|
+
// null means not to return pseudo styles
|
|
268
|
+
return win.getComputedStyle(el, null)[property]
|
|
269
|
+
}
|
|
270
|
+
</script>
|
|
271
|
+
|
|
272
|
+
<style lang="stylus">
|
|
273
|
+
$navbar-vertical-padding = 0.7rem
|
|
274
|
+
$navbar-horizontal-padding = 1.5rem
|
|
275
|
+
@import '../styles/navbar'
|
|
276
|
+
|
|
277
|
+
.navbar
|
|
278
|
+
// padding $navbar-vertical-padding $navbar-horizontal-padding
|
|
279
|
+
line-height $navbar-main-navbar-height // $navbarHeight - 1.4rem
|
|
280
|
+
a, span, img
|
|
281
|
+
display inline-block
|
|
282
|
+
.title-logo
|
|
283
|
+
.logo
|
|
284
|
+
height $navbar-logo-height // $navbarHeight - 1.4rem
|
|
285
|
+
// min-width $navbar-main-navbar-height // $navbarHeight - 1.4rem
|
|
286
|
+
margin-right 0.8rem
|
|
287
|
+
vertical-align top
|
|
288
|
+
.site-name
|
|
289
|
+
font-size 1.3rem
|
|
290
|
+
font-weight 600
|
|
291
|
+
color $textColor
|
|
292
|
+
position relative
|
|
293
|
+
.links
|
|
294
|
+
height 100%
|
|
295
|
+
// padding-left 1.5rem
|
|
296
|
+
box-sizing border-box
|
|
297
|
+
// background-color white
|
|
298
|
+
white-space nowrap
|
|
299
|
+
font-size 0.9rem
|
|
300
|
+
position absolute
|
|
301
|
+
right $navbar-horizontal-padding
|
|
302
|
+
top 0 //$navbar-vertical-padding
|
|
303
|
+
transition: top 0.1s ease 0s
|
|
304
|
+
display flex
|
|
305
|
+
.search-box
|
|
306
|
+
flex: 0 0 auto
|
|
307
|
+
vertical-align top
|
|
308
|
+
|
|
309
|
+
@media (max-width: $MQMobile)
|
|
310
|
+
.navbar
|
|
311
|
+
// padding-left 4rem
|
|
312
|
+
.can-hide
|
|
313
|
+
display none !important
|
|
314
|
+
.links
|
|
315
|
+
padding-left 0rem // 1.5rem
|
|
316
|
+
top 0 !important
|
|
317
|
+
.site-name
|
|
318
|
+
width calc(100vw - 9.4rem)
|
|
319
|
+
overflow hidden
|
|
320
|
+
white-space nowrap
|
|
321
|
+
text-overflow ellipsis
|
|
322
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<a href="https://www.dcloud.io" class="home-link">
|
|
3
|
+
<img
|
|
4
|
+
v-if="$site.themeConfig.logo"
|
|
5
|
+
class="logo"
|
|
6
|
+
:src="$withBase($site.themeConfig.logo)"
|
|
7
|
+
:alt="$siteTitle"
|
|
8
|
+
/>
|
|
9
|
+
<img
|
|
10
|
+
v-if="$site.themeConfig.titleLogo"
|
|
11
|
+
class="title-logo can-hide"
|
|
12
|
+
:src="$withBase($site.themeConfig.titleLogo)"
|
|
13
|
+
:alt="$siteTitle"
|
|
14
|
+
/>
|
|
15
|
+
<span
|
|
16
|
+
v-else-if="$siteTitle"
|
|
17
|
+
ref="siteName"
|
|
18
|
+
class="site-name"
|
|
19
|
+
:class="{ 'can-hide': $site.themeConfig.logo }"
|
|
20
|
+
>
|
|
21
|
+
{{ $siteTitle }}
|
|
22
|
+
</span>
|
|
23
|
+
</a>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span>
|
|
3
|
+
<svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px"
|
|
4
|
+
viewBox="0 0 100 100" width="15" height="15">
|
|
5
|
+
<path fill="currentColor"
|
|
6
|
+
d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z" />
|
|
7
|
+
<polygon fill="currentColor"
|
|
8
|
+
points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9" />
|
|
9
|
+
</svg>
|
|
10
|
+
<!-- <span class="sr-only">{{ openInNewWindowTitle }}</span> -->
|
|
11
|
+
</span>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
export default {
|
|
16
|
+
computed: {
|
|
17
|
+
openInNewWindowTitle() {
|
|
18
|
+
return this.$themeLocaleConfig.openNewWindowText || '(opens new window)'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<style>
|
|
25
|
+
.icon.outbound {
|
|
26
|
+
color: #aaa;
|
|
27
|
+
display: inline-block;
|
|
28
|
+
vertical-align: middle;
|
|
29
|
+
position: relative;
|
|
30
|
+
top: -1px;
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
33
|
+
|
|
34
|
+
<style lang="stylus">
|
|
35
|
+
.sr-only
|
|
36
|
+
position absolute
|
|
37
|
+
width 1px
|
|
38
|
+
height 1px
|
|
39
|
+
padding 0
|
|
40
|
+
margin -1px
|
|
41
|
+
overflow hidden
|
|
42
|
+
clip rect(0, 0, 0, 0)
|
|
43
|
+
white-space nowrap
|
|
44
|
+
border-width 0
|
|
45
|
+
</style>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _get = _interopRequireDefault(require("lodash/get"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
+
|
|
12
|
+
var _default = function _default(query, page) {
|
|
13
|
+
var additionalStr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
14
|
+
var domain = (0, _get["default"])(page, 'title', '');
|
|
15
|
+
|
|
16
|
+
if ((0, _get["default"])(page, 'frontmatter.tags')) {
|
|
17
|
+
domain += " ".concat(page.frontmatter.tags.join(' '));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (additionalStr) {
|
|
21
|
+
domain += " ".concat(additionalStr);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return matchTest(query, domain);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports["default"] = _default;
|
|
28
|
+
|
|
29
|
+
var matchTest = function matchTest(query, domain) {
|
|
30
|
+
var escapeRegExp = function escapeRegExp(str) {
|
|
31
|
+
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
32
|
+
}; // eslint-disable-next-line no-control-regex
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
var nonASCIIRegExp = new RegExp('[^\x00-\x7F]');
|
|
36
|
+
var words = query.split(/\s+/g).map(function (str) {
|
|
37
|
+
return str.trim();
|
|
38
|
+
}).filter(function (str) {
|
|
39
|
+
return !!str;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (!nonASCIIRegExp.test(query)) {
|
|
43
|
+
// if the query only has ASCII chars, treat as English
|
|
44
|
+
var hasTrailingSpace = query.endsWith(' ');
|
|
45
|
+
var searchRegex = new RegExp(words.map(function (word, index) {
|
|
46
|
+
if (words.length === index + 1 && !hasTrailingSpace) {
|
|
47
|
+
// The last word - ok with the word being "startswith"-like
|
|
48
|
+
return "(?=.*\\b".concat(escapeRegExp(word), ")");
|
|
49
|
+
} else {
|
|
50
|
+
// Not the last word - expect the whole word exactly
|
|
51
|
+
return "(?=.*\\b".concat(escapeRegExp(word), "\\b)");
|
|
52
|
+
}
|
|
53
|
+
}).join('') + '.+', 'gi');
|
|
54
|
+
return searchRegex.test(domain);
|
|
55
|
+
} else {
|
|
56
|
+
// if the query has non-ASCII chars, treat as other languages
|
|
57
|
+
return words.some(function (word) {
|
|
58
|
+
return domain.toLowerCase().indexOf(word) > -1;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|