Skip to content

Commit

Permalink
feat: add bookmarks page and enhance theme functionality
Browse files Browse the repository at this point in the history
- Added new bookmarks page layout and functionality
- Implemented scrollbar hiding for better UI
- Enhanced theme configuration handling for various data types
- Added support for custom bookmark images and fallback image
- Improved responsive design for bookmarks page
- Updated tailwind CSS with new utility classes and styles
  • Loading branch information
EvanNotFound committed Nov 18, 2024
1 parent 6d0546e commit 64f8cc1
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 2 deletions.
66 changes: 66 additions & 0 deletions layout/pages/bookmarks/bookmarks.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<div class="py-8 sm:py-0">


<h1 class="page-title-header">
<%- getPageTitle(page) %>
</h1>
<div class="flex flex-col md:flex-row gap-6 md:gap-12 w-full">


<!-- Left Sidebar - Categories -->
<div class="w-full md:w-64 flex-shrink-0 md:sticky md:top-[var(--navbar-height)] h-fit sm:py-6">
<nav class="flex md:block overflow-x-auto scrollbar-hide pb-4 md:pb-0 gap-2">
<% for (const category of theme.bookmarks) { %>
<a href="#<%= category.category.toLowerCase().replace(/\s+/g, '-') %>" class="whitespace-nowrap md:whitespace-normal block px-3 py-2 rounded-lg
hover:bg-second-background-color hover:text-primary hover:scale-102
transition-all duration-200 border border-transparent
hover:border-second-background-color
flex-shrink-0 font-medium">
<i class="fa-regular <%= category.icon %> mr-2 w-6 h-6"></i>
<%= category.category %>
</a>
<% } %>
</nav>
</div>

<!-- Right Content - Bookmarks -->
<div class="flex-1 max-w-full">
<% for (const category of theme.bookmarks) { %>
<section id="<%= category.category.toLowerCase().replace(/\s+/g, '-') %>" class="mb-12">
<h2 class="text-2xl font-semibold text-second-text-color mb-4 pb-2 border-b border-border-color">
<%= category.category %>
</h2>
<div class="grid gap-6 lg:grid-cols-2">
<% for (const item of category.items) { %>
<a href="<%= item.link %>" target="_blank" rel="noopener noreferrer" class="group block">
<div class="p-5 rounded-xl redefine-box-shadow-flat transition-all duration-300
hover:transform hover:-translate-y-1">
<div class="flex items-center gap-5">
<div class="w-12 h-12 rounded-xl overflow-hidden bg-second-background-color flex-shrink-0
transform group-hover:scale-105 transition-transform duration-300">
<img src="<%= item.image %>" alt="<%= item.name %>" class="w-full h-full object-cover" onerror="this.src='/images/default-bookmark.png'">
</div>
<div class="flex-1 min-w-0">
<div class="flex items-center justify-between">
<h3 class="font-medium text-second-text-color group-hover:text-primary transition-colors">
<%= item.name %>
</h3>
<i class="fa-regular fa-arrow-right text-third-text-color opacity-0 group-hover:opacity-100 -translate-x-1
group-hover:translate-x-0 transition-all duration-300"></i>
</div>
<p class="mt-2 text-sm text-third-text-color line-clamp-2">
<%= item.description %>
</p>
</div>
</div>
</div>
</a>
<% } %>
</div>
</section>
<% } %>
</div>
</div>

</div>
5 changes: 4 additions & 1 deletion scripts/dataHandle.js → scripts/data-handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ hexo.on('generateBefore', function () {
const data = hexo.locals.get('data');

if (data) {

// theme config file handle
if (data._config) {
hexo.theme.config = data._config;
Expand All @@ -29,6 +28,10 @@ hexo.on('generateBefore', function () {
hexo.theme.config.masonry = (data.masonry || data.gallery || data.photos);
}

if (data.bookmarks || data.tools) {
hexo.theme.config.bookmarks = data.bookmarks || data.tools;
}

}
}
});
6 changes: 6 additions & 0 deletions scripts/helpers/page-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ const pageData = {
partial: "pages/masonry/masonry",
layout: "default",
},
bookmarks: {
titles: ["bookmarks", "bookmark", "书签", "工具", "tools"],
types: ["bookmarks", "bookmark", "tools"],
partial: "pages/bookmarks/bookmarks",
layout: "raw",
},
pageTemplate: {
titles: [],
types: [],
Expand Down
2 changes: 1 addition & 1 deletion source/build/css/tailwind.css

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions source/css/common/basic.styl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ html, body
font-size $default-font-size
line-height $default-line-height

--navbar-height: $navbar-height

// Custom scrollbar
&::-webkit-scrollbar
width 14px
Expand Down Expand Up @@ -61,6 +63,9 @@ html, body
font-size: $default-font-size * 0.9
line-height: $default-line-height * 0.9

.navbar-shrink
--navbar-height: $navbar-shrink-height

// ======================================================================
// selection
// ======================================================================
Expand Down Expand Up @@ -159,3 +164,6 @@ button
// ======================================================================
.clear
clear both



9 changes: 9 additions & 0 deletions source/css/tailwind.source.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,13 @@
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}

.scrollbar-hide {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}

.scrollbar-hide::-webkit-scrollbar {
display: none; /* Chrome, Safari and Opera */
}

0 comments on commit 64f8cc1

Please sign in to comment.