页面加载中
博客快捷键
按住 Shift 键查看可用快捷键
ShiftK
开启/关闭快捷键功能
ShiftA
打开/关闭中控台
ShiftD
深色/浅色显示模式
ShiftS
站内搜索
ShiftR
随机访问
ShiftH
返回首页
ShiftL
友链页面
ShiftP
关于本站
ShiftI
原版/本站右键菜单
松开 Shift 键或点击外部区域关闭
互动
最近评论
暂无评论
标签
寻找感兴趣的领域
暂无标签
    0
    文章
    0
    标签
    8
    分类
    10
    评论
    128
    功能
    深色模式
    标签
    JavaScript12TypeScript8React15Next.js6Vue10Node.js7CSS5前端20
    互动
    最近评论
    暂无评论
    标签
    寻找感兴趣的领域
    暂无标签
      0
      文章
      0
      标签
      8
      分类
      10
      评论
      128
      功能
      深色模式
      标签
      JavaScript12TypeScript8React15Next.js6Vue10Node.js7CSS5前端20
      随便逛逛
      博客分类
      文章标签
      复制地址
      深色模式
      AnHeYuAnHeYu
      Search⌘K
      博客
        暂无其他文档

        Solitude主题魔改(一):首页三栏显示

        文章摘要
        本文提供了一篇针对Solitude主题的专项教程,旨在帮助用户升级或魔改主题。教程中详细介绍了如何修改CSS文件,特别是recent-post.styl文件中的10-240行代码,以优化显示效果。此外,文章还指出Butterfly系主题代码相似但存在差异,用户可参考修改。教程还涉及修改主题配置文件,具体到第309-313行的内容,包括调整index_post_list的方向、列数、内容显示方式以及截取内容长度等,以实现个性化的布局和内容展示。
        June 21, 20244 分钟 阅读60 次阅读
        ![](https://blog.byer.ink/api/f/Z3hMn/1767530193441651486.png)

        此教程会向Solitude提交pr,可以升级主题的人可以等待主题更新,不可以升级主题的可以直接照着魔改

        此教程是为Solitude主题的专项教程,其余Butterfly系主题代码相似,但不完全相同,可自行修改后食用

        打开themes\solitude\source\css\_layout\recent-post.styl文件:
        修改10-240行内容,将其全部替换为如下代码,注意代码的穿插位置:

        styl
        if hexo-config('index_post_list.direction') == "column"
          #recent-posts
            position relative
            +minWidth1300()
              display flex
              flex-wrap wrap
              gap .5rem
              transition width .3s
        
            +maxWidth768()
              padding 0 1rem
        
            > .recent-post-item
              box-shadow var(--efu-shadow-light2black)
              display flex
              align-items center
              animation slide-in .6s .4s backwards
              transition all .3s ease 0s
              overflow hidden
              height fit-content
              background var(--efu-card-bg)
              border-radius 12px
              cursor pointer
              border var(--style-border)
        
              +maxWidth1300()
                margin-bottom .5rem
        
              +maxWidth768()
                border-radius 12px
                border var(--style-border-always)
                box-shadow var(--efu-shadow-border)
                display block
                position relative
                clip-path inset(0 0 0 0 round 12px)
        
              &:hover
                box-shadow var(--efu-shadow-main)
                border var(--style-border-hover)
        
                .post_cover img.post_bg
                  transform scale(1.03)
                  transition .3s ease-in-out
                  filter brightness(.85)
        
                .recent-post-info-top .article-title
                  color var(--efu-theme)
        
              if hexo-config('google_adsense.enable')
                + .google-ads-warp
                  iframe
                    width: 100% !important
                    height: 100% !important
                    border: none !important
        
              .post_cover
                position relative
                transition 1s
                width 100%
                overflow hidden
                height 100%
        
                +minWidth1300()
                  height 225px
        
                +maxWidth1300()
                  width 75%
                  display flex
                  height 220px
        
                +maxWidth768()
                  width 100%
                  height 170px
                  border-radius 5px 8px 0 0
        
                a
                  min-width 100%
                  min-height 100%
        
                img.post_bg
                  width 100%
                  height 100%
                  transition all .6s ease 0s
                  object-fit cover
        
                  +maxWidth1300()
                    min-width 100%
                    -webkit-backface-visibility hidden
                    -webkit-transform-style preserve-3d
                    min-height 100%
                    user-select none
        
                  +maxWidth768()
                    border-radius: 12px 12px 0 0
        
              > .recent-post-info
                height 174px
                width 100%
                cursor pointer
                position relative
                padding 0
                display inline-block
                overflow hidden
        
                .content
                  -webkit-line-clamp 2
                  display -webkit-box
                  overflow hidden
                  -webkit-box-orient vertical
                  padding 5px 32px
                  opacity .8
                  font-size 14px
                  line-height 1.8
        
                  +maxWidth600()
                    -webkit-line-clamp 1
        
                span.tags-punctuation
                  transition .3s
        
                  &:hover
                    color var(--efu-main)
        
                .recent-post-info-top
                  position relative
                  transition .3s
                  padding 0 32px
                  width 100%
        
                  .article-title
                    line-height 30px
                    margin-top 0
                    font-weight 700
                    margin-bottom 0
                    width 100%
                    transition .3s
                    font-size 1rem
                    -webkit-line-clamp 2
                    display -webkit-box
                    overflow hidden
                    -webkit-box-orient vertical
        
                  .recent-post-info-top-tips
                    display flex
                    margin-top 20px
                    user-select none
        
                    > .sticky-warp
                      display flex
                      position relative
                      margin-right 8px
                      justify-content center
                      align-items center
                      font-size 0.5rem
        
                      i
                        font-size .5rem
                        margin-right 3px
        
                    .original
                      display flex
                      color var(--efu-secondtext)
                      font-size .5rem
                      position relative
                      margin-right 8px
        
                    .unvisited-post
                      display flex
                      color var(--efu-secondtext)
                      font-size .5rem
                      position relative
        
                      &:visited
                        color var(--efu-card-bg)
        
                /.article-meta-wrap
                  position absolute
                  bottom 16px
                  transition .3s
                  display flex
                  flex-direction row
                  flex-wrap nowrap
                  justify-content space-between
                  width 100%
                  left 0
                  padding 0 32px
                  white-space nowrap
                  color var(--efu-fontcolor)
                  font-size .7rem
        
                  > .article-meta
                    margin 0 8px 0 0
                    white-space nowrap
                    overflow hidden
                    text-overflow ellipsis
                    display flex
        
                    > .article-meta__tags
                      margin-right 8px
                      padding 0 .2rem 0 0
                      color var(--efu-fontcolor)
        
                  > .post-meta-date
                    right 0
                    text-align right
        
                    i
                      display none
        
                  .article-meta__separator
                    display none
        
                  a:hover
                    background-color var(--efu-none)
                    color var(--efu-lighttext)
                    cursor pointer
                    border-radius 4px
        
                  i
                    margin 0 .4rem 0 0
        
                  .sticky
                    color var(--efu-fontcolor)
        
          if hexo-config('index_post_list.direction') == "column" && hexo-config('index_post_list.column') == 2
            #recent-posts
              > .recent-post-item
                +minWidth1300()
                  flex-direction column
                  width 100%
                  flex 1 1 40%
                  max-width 50%
                  box-shadow var(--efu-shadow-border)
          else if hexo-config('index_post_list.direction') == "column" && hexo-config('index_post_list.column') == 3
            #recent-posts
              > .recent-post-item
                +minWidth1300()
                  flex-direction column
                  width 100%
                  flex 1 1 33.3%
                  max-width 32.6%
                  box-shadow var(--efu-shadow-border)

        修改主题配置
        修改第309-313行内容:

        yml
        index_post_list:
          direction: column # row / column
          column: 3 #2:2列 3:3列
          content: false # 1: post.description / 2: 自动获取description或截取内容(Automatically get descriptions or screenshots) / 3: 只使用截取内容(Use only screenshots) / false: 不显示内容(No content is displayed)
          length: 500 # 截取内容的长度 : The length of the screenshot content
          cover: both # left: 在左侧 : left / right: 在右侧 : right / both: 两侧 : both

        当direction为column时,column设置为3即为首页三栏,column为2即为默认的两栏

        最后更新于 June 21, 2024
        On this page
        暂无目录