Browse Source

更新数据库文件,增强文章控制器的搜索功能,调整文章视图模板的样式以提升用户体验

re
谢亚昕 3 months ago
parent
commit
87c3ab2998
  1. BIN
      database/development.sqlite3-wal
  2. 4
      docs/links.md
  3. 5
      src/controllers/Page/ArticleController.js
  4. 8
      src/views/page/index/index.pug

BIN
database/development.sqlite3-wal

Binary file not shown.

4
docs/links.md

@ -5,3 +5,7 @@ https://trix-editor.org/js/attachments.js
https://github.com/basecamp/trix/tree/main
https://icon-sets.iconify.design/?query=info
## 编辑器推荐
https://www.ewebeditor.net/demo/quickformat.asp

5
src/controllers/Page/ArticleController.js

@ -97,6 +97,11 @@ class ArticleController {
async search(ctx) {
const { q } = ctx.query
if(!q) {
return ctx.set('hx-redirect', '/articles')
}
const articles = await ArticleModel.searchByKeyword(q)
return ctx.render("page/articles/search", {

8
src/views/page/index/index.pug

@ -14,19 +14,19 @@ mixin item(url, desc)
mixin card(blog)
.article-card(class="bg-white rounded-[12px] shadow p-6 transition hover:shadow-lg border border-gray-100")
h3.article-title(class="text-lg font-semibold text-gray-900 mb-2")
a(href="/articles/"+blog.slug class="hover:text-blue-600 transition-colors duration-200") #{blog.title}
div(class="transition-colors duration-200") #{blog.title}
if blog.status === "draft"
span(class="ml-2 px-2 py-0.5 text-xs bg-yellow-200 text-yellow-800 rounded align-middle") 未发布
p.article-meta(class="text-sm text-gray-400 mb-3 flex")
span(class="mr-2 line-clamp-1" title=blog.author)
span 作者:
a(href=blog.author class="hover:text-blue-600 transition-colors duration-200") #{blog.author}
span(class="transition-colors duration-200") #{blog.author}
span(class="mr-2 whitespace-nowrap")
span |
a(href=blog.updated_at.slice(0, 10) class="hover:text-blue-600 transition-colors duration-200") #{blog.updated_at.slice(0, 10)}
span(class="transition-colors duration-200") #{blog.updated_at.slice(0, 10)}
span(class="mr-2 whitespace-nowrap")
span | 分类:
a(href=blog.category class="hover:text-blue-600 transition-colors duration-200") #{blog.category}
a(href=`/articles/category/${blog.category}` class="hover:text-blue-600 transition-colors duration-200") #{blog.category}
p.article-desc(
class="text-gray-600 text-base mb-4 line-clamp-2"
style="height: 2.8em; overflow: hidden;"

Loading…
Cancel
Save