Skip to content

Commit

Permalink
feat: banner srcset支持
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon committed Jun 9, 2024
1 parent cf88b2c commit 428ae68
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@ menu:
banner: "/images/banner.webp" # themes/reimu/source/images/banner.webp
# You can also write it in the form of the following url
# banner: "https://example.com"
banner_srcset:
enable: false
srcset:
- src: "/images/banner-600w.webp"
media: "(max-width: 479px)"
- src: "/images/banner-800w.webp"
media: "(max-width: 799px)"
- src: "/images/banner.webp"
media: "(min-width: 800px)"
favicon: "/images/favicon.ico" # themes/reimu/source/images/favicon.ico
# You can also write it in the form of the following url
# favicon: "https://example.com"
avatar: "avatar.webp" # source/_data/avatar/avatar.webp


# Content
excerpt_link: Read More

Expand Down
11 changes: 10 additions & 1 deletion layout/_partial/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@
<% } else if (post.cover == false) { %>
<% } else { %>
<img fetchpriority="high" src="<%- url_for(theme.banner, {relative: false}) %>" alt="<%= post.title %>">
<% if (theme.banner_srcset.enable) { %>
<picture>
<% for (var i of theme.banner_srcset.srcset) { %>
<source media="<%= i.media %>" srcset="<%- url_for(i.src, {relative: false}) %>">
<% } %>
<img fetchpriority="high" src="<%- url_for(theme.banner, {relative: false}) %>" alt="<%= post.title %>">
</picture>
<% } else { %>
<img fetchpriority="high" src="<%- url_for(theme.banner, {relative: false}) %>" alt="<%= post.title %>">
<% } %>
<% } %>
<div id="header-outer" class="outer">
<div id="header-title" class="inner">
Expand Down
Binary file added source/images/banner-600w.webp
Binary file not shown.
Binary file added source/images/banner-800w.webp
Binary file not shown.
Binary file modified source/images/banner.webp
Binary file not shown.

0 comments on commit 428ae68

Please sign in to comment.