mirror of https://gitlab.com/curben/blog
feat(theme-nav): remove nav link for current page
- reimplement in js, avoid disabling hexo layout caching
- revert f9889702b7
This commit is contained in:
parent
748fec2f1d
commit
056d4389ab
|
@ -1,5 +1,5 @@
|
||||||
<article id="<%= post.layout %>-<%= post.slug %>" class="h-entry article article-type-<%= post.layout %>" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
|
<article id="<%= post.layout %>-<%= post.slug %>" class="h-entry article article-type-<%= post.layout %>" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
|
||||||
<%- partial('_partial/header', {}, { cache: false }) %>
|
<%- partial('_partial/header', {}, { cache: true }) %>
|
||||||
<hr class="header-hr">
|
<hr class="header-hr">
|
||||||
<div class="article-inner">
|
<div class="article-inner">
|
||||||
<%- partial('post/gallery') %>
|
<%- partial('post/gallery') %>
|
||||||
|
|
|
@ -4,11 +4,7 @@
|
||||||
<% if (!theme.menu) { %><a class="main-nav-link" href="<%- config.root %>">Home</a>
|
<% if (!theme.menu) { %><a class="main-nav-link" href="<%- config.root %>">Home</a>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<% for (const i in theme.menu) { %>
|
<% for (const i in theme.menu) { %>
|
||||||
<% if (url_for(theme.menu[i]) !== url_for(page.path)) { %>
|
|
||||||
<a class="main-nav-link" href="<%- url_for(theme.menu[i]) %>"><%= i %></a>
|
<a class="main-nav-link" href="<%- url_for(theme.menu[i]) %>"><%= i %></a>
|
||||||
<% } else { %>
|
|
||||||
<span class="main-nav-link"><%= i %></span>
|
|
||||||
<% } %>
|
|
||||||
<% }} %>
|
<% }} %>
|
||||||
|
|
||||||
<div class="search-container">
|
<div class="search-container">
|
||||||
|
@ -55,11 +51,7 @@
|
||||||
<% if (!theme.menu) { %><a class="mobile-nav-link-a" href="<%- config.root %>">Home</a>
|
<% if (!theme.menu) { %><a class="mobile-nav-link-a" href="<%- config.root %>">Home</a>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<% for (const i in theme.menu) { %>
|
<% for (const i in theme.menu) { %>
|
||||||
<% if (url_for(theme.menu[i]) !== url_for(page.path)) { %>
|
|
||||||
<a class="mobile-nav-link-a" href="<%- url_for(theme.menu[i]) %>"><%= i %></a>
|
<a class="mobile-nav-link-a" href="<%- url_for(theme.menu[i]) %>"><%= i %></a>
|
||||||
<% } else { %>
|
|
||||||
<span class="mobile-nav-link-a"><%= i %></span>
|
|
||||||
<% } %>
|
|
||||||
<% }} %>
|
<% }} %>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="archive-container">
|
<div class="archive-container">
|
||||||
<%- partial('_partial/header', {}, { cache: false }) %>
|
<%- partial('_partial/header', {}, { cache: true }) %>
|
||||||
<hr class="header-hr"/>
|
<hr class="header-hr"/>
|
||||||
<%- partial('_partial/archive', {pagination: config.archive, index: true}) %>
|
<%- partial('_partial/archive', {pagination: config.archive, index: true}) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="archive-container">
|
<div class="archive-container">
|
||||||
<%- partial('_partial/header', {}, { cache: false }) %>
|
<%- partial('_partial/header', {}, { cache: true }) %>
|
||||||
<hr class="header-hr"/>
|
<hr class="header-hr"/>
|
||||||
<h2>Recent posts:</h2>
|
<h2>Recent posts:</h2>
|
||||||
<%- list_posts({
|
<%- list_posts({
|
||||||
|
|
|
@ -55,3 +55,15 @@ if (document.location.hostname.endsWith('.onion')) {
|
||||||
form.setAttribute('action', 'https://3g2upl4pq6kufc4m.onion/')
|
form.setAttribute('action', 'https://3g2upl4pq6kufc4m.onion/')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove navigation link of current page
|
||||||
|
const navLink = document.querySelectorAll('a.main-nav-link, a.mobile-nav-link-a')
|
||||||
|
navLink.forEach((ele) => {
|
||||||
|
const eleHref = new URL(ele.href)
|
||||||
|
if (eleHref.pathname === document.location.pathname) {
|
||||||
|
const span = document.createElement('span')
|
||||||
|
span.className = ele.className
|
||||||
|
span.textContent = ele.textContent
|
||||||
|
ele.outerHTML = span.outerHTML
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue