feat: detect in repo page with DOM element

This commit is contained in:
EnixCoda 2018-10-08 22:33:19 +08:00
parent d60f85dfe8
commit 29ad80f6ac

View file

@ -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