-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
104 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 17 additions & 17 deletions
34
packages/vuepress-common/src/components/molecules/api-symbol/ApiSymbolQuery.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
<template> | ||
<ApiSymbol v-if="item.length" :item="item[0]"/> | ||
<span v-else-if="query">Unable to find something: <code>{{this.query}}</code></span> | ||
<span v-else-if="query">Unable to find something: <code>{{ this.query }}</code></span> | ||
</template> | ||
<script> | ||
import ApiSymbol from './ApiSymbol' | ||
import ApiSymbol from './ApiSymbol' | ||
export default { | ||
name: 'ApiSymbolQuery', | ||
components: { | ||
ApiSymbol | ||
}, | ||
props: { | ||
query: { | ||
type: String, | ||
default: '' | ||
} | ||
}, | ||
computed: { | ||
item () { | ||
return this.$filterSymbols(this.query) | ||
} | ||
export default { | ||
name: 'ApiSymbolQuery', | ||
components: { | ||
ApiSymbol | ||
}, | ||
props: { | ||
query: { | ||
type: String, | ||
default: '' | ||
} | ||
}, | ||
computed: { | ||
item() { | ||
return this.filterSymbols(this.query) | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import './styles/index.css' | ||
|
||
export * from './components' | ||
export * from './mixins/ApiMixin' | ||
export * from './utils' | ||
export * from './clients/GithubClient' | ||
export * from './clients/OpenCollectiveClient' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {filterSymbols} from '../utils' | ||
|
||
export const ApiMixin = { | ||
created() { | ||
|
||
}, | ||
methods: { | ||
getApi() { | ||
return this.$themeConfig.api || {} | ||
}, | ||
getApiModules() { | ||
const modules = this.getApi() | ||
|
||
if (!modules) { | ||
return {} | ||
} | ||
|
||
return Object.keys(modules) | ||
.sort((a, b) => a < b ? -1 : 1) | ||
.reduce((acc, key) => { | ||
|
||
const symbols = modules[key] | ||
.symbols | ||
.filter((symbol) => { | ||
if (!!(this.currentType && symbol.symbolType !== this.currentType)) { | ||
return false | ||
} | ||
|
||
if (!!(this.currentStatus && symbol.status.indexOf(this.currentStatus))) { | ||
return false | ||
} | ||
|
||
if (!!this.keyword) { | ||
return symbol.symbolName.toLowerCase().indexOf(this.keyword.toLocaleLowerCase()) > -1 | ||
} | ||
|
||
return true | ||
}) | ||
|
||
acc[key] = {...modules[key], symbols} | ||
|
||
return acc | ||
}, {}) | ||
}, | ||
getApiRedirectUrl() { | ||
return this.$themeConfig.apiRedirectUrl || '' | ||
}, | ||
filterSymbols(query) { | ||
const items = filterSymbols(this.getApi())(query) | ||
|
||
return items.map((item) => { | ||
return { | ||
...item, | ||
link: this.getApiLink(item) | ||
} | ||
}) | ||
}, | ||
getApiLink(item) { | ||
return `${this.getApiRedirectUrl()}${item.path.replace(/\/\//gi, '/')}.html` | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters