refactor: 左侧边栏折叠功能
This commit is contained in:
parent
a381f3b419
commit
87ba77fdc4
|
@ -1,15 +1,5 @@
|
|||
<script>
|
||||
let isOpenLeftSide = true;
|
||||
const foldLeftSide = () => {
|
||||
document.querySelector('.page-left').style.display = isOpenLeftSide ? 'none' : 'block';
|
||||
document.querySelector('.page-right').style.width = isOpenLeftSide ? '100%' : '<%= theme.page.right_side_width + '%' %>';
|
||||
isOpenLeftSide = !isOpenLeftSide;
|
||||
};
|
||||
</script>
|
||||
<nav class="nav">
|
||||
<button class="fold-left-side-btn"
|
||||
onclick="foldLeftSide()"
|
||||
>
|
||||
<button class="fold-left-side-btn">
|
||||
<i class="fa fa-bars"></i>
|
||||
</button>
|
||||
<ul class="menu-list">
|
||||
|
|
|
@ -14,7 +14,8 @@ hexo.extend.helper.register('export_config', function() {
|
|||
root : config.root,
|
||||
localsearch: theme.local_search,
|
||||
themeName: theme.theme_name,
|
||||
themeVersion: theme.theme_version
|
||||
themeVersion: theme.theme_version,
|
||||
pageLayout: theme.page
|
||||
};
|
||||
if (config.search) {
|
||||
exportConfig.path = config.search.path;
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
window.addEventListener('DOMContentLoaded', () => {
|
||||
console.log(`${CONFIG.themeName} v${CONFIG.themeVersion}`);
|
||||
|
||||
let isOpenLeftSide = true;
|
||||
document.querySelector('.fold-left-side-btn').addEventListener('click', () => {
|
||||
document.querySelector('.page-left').style.display = isOpenLeftSide ? 'none' : 'block';
|
||||
document.querySelector('.page-right').style.width = isOpenLeftSide ? '100%' : `${CONFIG.pageLayout.right_side_width}%`;
|
||||
isOpenLeftSide = !isOpenLeftSide;
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue