🚀 feat: custom layoutWidth

This commit is contained in:
shenyu 2020-03-29 18:18:22 +08:00
parent b4f1246c53
commit 79b014ab4a
7 changed files with 52 additions and 17 deletions

View File

@ -98,7 +98,7 @@ cover:
logo: /images/ayer.svg logo: /images/ayer.svg
# ProgressBar # ProgressBar
progressBar: ture progressBar: true
# Article Setting # Article Setting
# (Use this to excerpt if article is too long<!--more-->) # (Use this to excerpt if article is too long<!--more-->)
@ -156,6 +156,11 @@ rss: /atom.xml
# DarkMode # DarkMode
darkmode: true darkmode: true
# articleWidth and sidebarWidth
layout:
article_width: 80rem
sidebar_width: 8rem
# Comment1、Valine (recommended)2、Gitalk # Comment1、Valine (recommended)2、Gitalk
# 1、Valine [A fast, simple & powerful comment system](https://github.com/xCss/Valine) # 1、Valine [A fast, simple & powerful comment system](https://github.com/xCss/Valine)

View File

@ -27,8 +27,6 @@ logo: /images/ayer-side.svg
# 封面配置 # 封面配置
# enable-是否启用封面path-封面背景图logo-封面logo # enable-是否启用封面path-封面背景图logo-封面logo
cover: cover:
enable: true enable: true
path: /images/cover1.jpg # images目录下附送多张美图可更换 path: /images/cover1.jpg # images目录下附送多张美图可更换
@ -37,14 +35,6 @@ cover:
# 页面顶部进度条 # 页面顶部进度条
progressBar: true progressBar: true
# 网易云音乐插件
music:
enable: false
# 播放器尺寸类型(1小尺寸、2大尺寸)
type: 1
id: 22707008 # 网易云分享的音乐ID(更换音乐请更改此配置项)
autoPlay: true # 是否开启自动播放
# 文章配置 # 文章配置
# 文章太长,截断按钮文字(在需要截断的行增加此标记:<!--more-->) # 文章太长,截断按钮文字(在需要截断的行增加此标记:<!--more-->)
excerpt_link: 阅读更多... excerpt_link: 阅读更多...
@ -103,6 +93,11 @@ rss: /atom.xml
# 是否启用黑夜模式开关 # 是否启用黑夜模式开关
darkmode: true darkmode: true
# 页面宽度自定义不建议修改可能造成布局混乱article_width文章宽度sidebar_width侧边栏宽度
layout:
article_width: 80rem
sidebar_width: 8rem
# 评论1、Valine(推荐)2、Gitalk # 评论1、Valine(推荐)2、Gitalk
# 1、Valine[一款快速、简洁且高效的无后端评论系统](https://github.com/xCss/Valine) # 1、Valine[一款快速、简洁且高效的无后端评论系统](https://github.com/xCss/Valine)
@ -133,6 +128,14 @@ github:
# (关闭请设置为false) # (关闭请设置为false)
url: https://github.com/Shen-Yu/hexo-theme-ayer url: https://github.com/Shen-Yu/hexo-theme-ayer
# 网易云音乐插件
music:
enable: false
# 播放器尺寸类型(1小尺寸、2大尺寸)
type: 1
id: 22707008 # 网易云分享的音乐ID(更换音乐请更改此配置项)
autoPlay: true # 是否开启自动播放
# 访问量统计(不蒜子) # 访问量统计(不蒜子)
busuanzi: busuanzi:
enable: true enable: true

View File

@ -29,6 +29,7 @@
<link rel="shortcut icon" href="<%- theme.favicon %>" /> <link rel="shortcut icon" href="<%- theme.favicon %>" />
<% } %> <% } %>
<%- css('dist/main') %> <%- css('dist/main') %>
<%- css('custom') %>
<% if (theme.progressBar){ %> <% if (theme.progressBar){ %>
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
<% } %> <% } %>

View File

@ -30,7 +30,6 @@
overflow-x: hidden overflow-x: hidden
-webkit-overflow-scrolling touch -webkit-overflow-scrolling touch
&.on &.on
transform translateX(aside-width)
margin-left 0 !important margin-left 0 !important
.sidebar .sidebar
@ -64,11 +63,11 @@
font-size larger font-size larger
.wrap, .outer .wrap, .outer
position relative
width 100% width 100%
padding-right gutter-width padding-right gutter-width
padding-left gutter-width padding-left gutter-width
margin auto margin auto
overflow-x hidden
min-height calc( 100% - 157px ) min-height calc( 100% - 157px )
clearfix() clearfix()

View File

@ -1,10 +1,12 @@
.tocbot .tocbot
position absolute position absolute
right: -28rem
top 14rem top 14rem
left calc((100vw - 70rem) / 2 + 70rem)
font-size 80% font-size 80%
opacity .8 opacity .95
max-width 230px
border-radius 8px
> .toc-list > .toc-list
position relative position relative
overflow hidden overflow hidden
@ -35,7 +37,8 @@ a.toc-link
.is-position-fixed .is-position-fixed
position fixed !important position fixed !important
top 0 top 0
right aside-width right 6rem
background-color #fff
// Left line before pseudo element. // Left line before pseudo element.
.toc-link::before .toc-link::before

24
source/custom.styl Normal file
View File

@ -0,0 +1,24 @@
$wrap-width = convert(hexo-config('layout.article_width'))
$aside-width = convert(hexo-config('layout.sidebar_width'))
.sidebar
left - $aside-width
width $aside-width
&.on
left 0
.content
&.on
margin-left 0 !important
.navbar-toggle
left 1.5rem + $aside-width
.search-form-wrap
right $aside-width
@media(min-width: 768px)
.outer, .wrap
width $wrap-width !important
@media(max-width: 768px)
.content
&.on
transform translateX($aside-width)

File diff suppressed because one or more lines are too long