博客添加待办清单页

2023-05-02 14:52:16 浏览数 (1)

参考:博客添加待办清单页

1. 前言

要做的事还有很多,想做的事源源不断,那就都记录在博客里吧,ToDoList。

2. 实现

  1. 新建 [blogroot]themesbutterflylayoutincludespagetodolist.pug 添加以下代码
代码语言:javascript复制
#todolist-box
    .page-top-card(style='background-image: url(/img/todo.webp);')
        .content-item-tips 想做清单
        span.content-item-title ToDoList
        .content-bottom
            .tips 要做的事还有很多,想做的事源源不断
    #todolist-main
        #todolist-left
            each i in site.data.todolist
                if i.seat == 'left'
                    .todolist-item
                        h3.todolist-title=i.class_name
                        ul.todolist-ul
                            each item in i.todo_list
                                li.todolist-li
                                    if item.completed
                                        i.fa-regular.fa-circle-check
                                    else 
                                        i.fa-regular.fa-circle
                                    span=item.content
        #todolist-right
            each i in site.data.todolist
                if i.seat == 'right'
                    .todolist-item
                        h3.todolist-title=i.class_name
                        ul.todolist-ul
                            each item in i.todo_list
                                li.todolist-li
                                    if item.completed
                                        i.fa-regular.fa-circle-check
                                    else 
                                        i.fa-regular.fa-circle
                                    span=item.content
  1. 修改 [blogroot]themesbutterflylayoutpage.pug
代码语言:javascript复制
case page.type
    when 'tags'
        include includes/page/tags.pug
        include includes/page/default-page.pug
    when 'link'
        include includes/page/flink.pug
    when 'categories'
        include includes/page/categories.pug
        include includes/page/default-page.pug
    when 'essay'
        include includes/page/essay.pug
     when 'todolist'
         include includes/page/todolist.pug
    default
        include includes/page/default-page.pug
  1. 新建 [blogroot]source_datatodolist.yml 添加以下代码
代码语言:javascript复制
- class_name: 想做的项目
  seat: left
  todo_list:
    - content: 个人主页
      completed: false
    - content: 公众号
      completed: false

- class_name: 想看的书
  seat: left
  todo_list:
    - content: 《毛泽东选集》
      completed: false
    - content: 《86不存在的战区》
      completed: false

- class_name: 想买的东西
  seat: left
  todo_list:
    - content: 小米平板5pro
      completed: true
    - content: 致态固态硬盘
      completed: true

- class_name: 想学的技术
  seat: right
  todo_list:
    - content: Vue2/Vue3
      completed: false
    - content: Electron
      completed: false

- class_name: 想去的地方
  seat: right
  todo_list:
    - content: 桂林
      completed: true
    - content: 杭州
      completed: false
  1. 添加CSS样式:
代码语言:javascript复制
#todolist-box{
    margin: 0 10px;
}
#todolist-main{
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    margin: 16px 0 10px;
}
#todolist-main li{
    list-style:none;
    font-size: 17px;
}
#todolist-main ul{
    margin: 0;
    padding: 0;
}
#todolist-left{
    width: 50%;
    padding: 0 8px 0 0;
}
#todolist-right{
    width: 50%;
    padding: 0 0 0 8px;
}
.todolist-item{
    position: relative;
    background: #fae4df;
    border-radius: 12px;
    padding: 10px 1rem 1.2rem;
    border: 2px dashed #f7a796;
    margin-bottom: 1rem;
}
[data-theme=dark]
.todolist-item{
    background: #242424;
    border: 2px dashed #51908b;
}
li.todolist-li i{
    margin-left: 10px;
}
h3.todolist-title{
    margin: 0!important;
    border-bottom: var(--todo-border);
}
li.todolist-li{
    border-bottom: var(--todo-border);
    font-weight: normal;
}
.todolist-li span{
    margin-left: 5px;
}
@media screen and (max-width:700px){
    #todolist-left,#todolist-right{
        width: 100%;
        padding: 0;
    }
  }
.page-top-card{
  background-size: cover;
  background-position: center;
  height: 20.5rem;
  padding: 10px 2.7rem;
  border-radius: 20px;
  color: white;
  position: relative;
}
.page-top-card span.content-item-title{
  font-size: 2.3em;
  font-weight: bold;
  line-height: 1.2;
  font-family: STZhongsong,'Microsoft YaHei';
}
.page-top-card .content-bottom{
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: absolute;
  width: calc(100% - 5.4rem);
  bottom: 1rem;
}
[data-theme='dark'] .page-top-card{
  opacity: .92;
}
  1. 新建页面,通过hexo n page todolist创建页面,相信都很熟悉了
代码语言:javascript复制
---
title: ToDoList
date: 2023-03-18 14:07:13
comments: false
aside: false
type: todolist
---

3. 后记

后来我有这么多想要做的事情。

0 人点赞