@vuepress-reco/style-default
Version:
It is default type of vuepress-theme-reco.
62 lines (61 loc) • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const vue_1 = require("vue");
const composables_1 = require("../composables/");
exports.default = vue_1.defineComponent({
setup(props, ctx) {
// const route = useRoute()
// const instance = useInstance()
// const headers = computed(() => {
// return instance.$showSubSideBar ? instance.$page.headers : []
// })
const headers = composables_1.usePageHeaders();
// const isActive = (route, path) => {
// const routeHash = route.hash
// const linkHash = getHash(path)
// if (linkHash && routeHash !== linkHash) {
// return false
// }
// const routePath = normalize(route.path)
// const pagePath = normalize(path)
// return routePath === pagePath
// }
// const isLinkActive = (header) => {
// const active = isActive(
// instance.$route,
// instance.$page.path + '#' + header.slug
// )
// if (active) {
// setTimeout(() => {
// document.querySelector(`.reco-side-${header.slug}`).scrollIntoView()
// }, 300)
// }
// return active
// }
return { headers };
},
render() {
return vue_1.h('ul', {
class: { 'sub-sidebar-wrapper': true, 'pageHeaders-container': true },
style: { width: this.headers.length > 0 ? '12rem' : '0' },
}, [
...this.headers.map((header) => {
return vue_1.h('li', {
class: {
// active: this.isLinkActive(header),
[`level-${header.level}`]: true,
},
key: header.title,
}, [
vue_1.h('RouterLink', {
class: {
'sidebar-link': true,
[`reco-side-${header.slug}`]: true,
},
// props: { to: `${this.$page.path}#${header.slug}` },
}, header.title),
]);
}),
]);
},
});