mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
feat: detect in repo page with DOM element
This commit is contained in:
parent
d60f85dfe8
commit
29ad80f6ac
1 changed files with 5 additions and 10 deletions
|
|
@ -24,7 +24,11 @@ function parse() {
|
|||
return parsedData
|
||||
}
|
||||
|
||||
const RESERVED_NAME = ['blog', 'settings', 'orgs']
|
||||
function isInRepoPage() {
|
||||
const repoHeaderSelector = '.repohead'
|
||||
return Boolean(document.querySelector(repoHeaderSelector))
|
||||
}
|
||||
|
||||
// route types related to determining if sidebar should show
|
||||
const TYPES = {
|
||||
TREE: 'tree',
|
||||
|
|
@ -34,15 +38,6 @@ const TYPES = {
|
|||
// TODO: record more types
|
||||
}
|
||||
|
||||
function isInRepoPage(metaData) {
|
||||
const { userName, repoName } = metaData || parseRaw()
|
||||
return Boolean(
|
||||
userName &&
|
||||
!RESERVED_NAME.find(_ => _ === userName) &&
|
||||
repoName
|
||||
)
|
||||
}
|
||||
|
||||
function isInCodePage(metaData = {}) {
|
||||
const mergedRepo = { ...parseRaw(), ...metaData }
|
||||
const { type, branchName } = mergedRepo
|
||||
|
|
|
|||
Loading…
Reference in a new issue