Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issues #401 #558

Merged
merged 7 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions assets/css/_core/_media.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
.page {
width: 100%;

[header-mobile] & {
[data-header-mobile] & {
padding-top: $header-height;
}

[header-mobile=normal] & {
[data-header-mobile=normal] & {
padding-top: 0;
}

Expand Down
2 changes: 1 addition & 1 deletion assets/css/_page/_home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
}
}

.home[posts] {
.home[data-home=posts] {
.home-profile {
@include transform(translateY(0));
padding-top: 2rem;
Expand Down
4 changes: 2 additions & 2 deletions assets/css/_page/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
width: 60%;
margin: 0 auto;

[header-desktop] & {
[data-header-desktop] & {
padding-top: $header-height;
}

[header-desktop=normal] & {
[data-header-desktop=normal] & {
padding-top: 0;
}

Expand Down
4 changes: 2 additions & 2 deletions assets/css/_partial/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ header {
height: $header-height;
line-height: $header-height;

[header-desktop=normal] & {
[data-header-desktop=normal] & {
position: static;
}

Expand Down Expand Up @@ -216,7 +216,7 @@ header {
height: $header-height;
line-height: $header-height;

[header-mobile=normal] & {
[data-header-mobile=normal] & {
position: static;
}

Expand Down
4 changes: 2 additions & 2 deletions assets/css/_partial/_single/_toc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
left: 0;
visibility: hidden;

[header-desktop=normal] & {
[data-header-desktop=normal] & {
top: 5rem;
}

Expand Down Expand Up @@ -116,7 +116,7 @@
display: none;
margin: .8rem 0;

&[kept=true] {
&[data-kept=true] {
display: block;
}

Expand Down
4 changes: 2 additions & 2 deletions assets/js/theme.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/theme.min.js.map

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noodp" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<title>
{{- block "title" . }}{{ .Site.Title }}{{ end -}}
</title>
Expand All @@ -15,7 +14,7 @@
{{- partial "head/link.html" . -}}
{{- partial "head/seo.html" . -}}
</head>
<body header-desktop="{{ .Site.Params.header.desktopMode }}" header-mobile="{{ .Site.Params.header.mobileMode }}">
<body data-header-desktop="{{ .Site.Params.header.desktopMode }}" data-header-mobile="{{ .Site.Params.header.mobileMode }}">
{{- /* Check theme isDark before body rendering */ -}}
{{- $theme := .Site.Params.defaulttheme -}}
<script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('{{ $theme }}' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : '{{ $theme }}' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>
Expand Down
2 changes: 1 addition & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{- $profile := .Site.Params.home.profile -}}
{{- $posts := .Site.Params.home.posts -}}

<div class="page home"{{ if ne $posts.enable false }} posts{{ end }}>
<div class="page home"{{ if ne $posts.enable false }} data-home="posts"{{ end }}>
{{- /* Profile */ -}}
{{- if ne $profile.enable false -}}
{{- partial "home/profile.html" . -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</div>
{{- end -}}

<div class="footer-line">
<div class="footer-line" itemscope itemtype="http://schema.org/CreativeWork">
{{- /* Copyright year */ -}}
{{- if ne .Site.Params.footer.copyright false -}}
<i class="far fa-copyright fa-fw"></i>
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/home/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ <h1 class="home-title">
{{- end -}}

{{- with $profile.subtitle -}}
<h2 class="home-subtitle">
<div class="home-subtitle">
{{- if $profile.typeit -}}
{{- $id := dict "Content" . "Scratch" $.Scratch | partial "function/id.html" -}}
<div id="{{ $id }}" class="typeit"></div>
{{- dict $id (slice $id) | dict "typeitMap" | merge ($.Scratch.Get "this") | $.Scratch.Set "this" -}}
{{- else -}}
{{- . -}}
{{- end -}}
</h2>
</div>
{{- end -}}

{{- if $profile.social -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h2 class="single-subtitle">{{ . }}</h2>

{{- /* Static TOC */ -}}
{{- if ne $toc.enable false -}}
<div class="details toc" id="toc-static" kept="{{ if $toc.keepStatic }}true{{ end }}">
<div class="details toc" id="toc-static" data-kept="{{ if $toc.keepStatic }}true{{ end }}">
<div class="details-summary toc-title">
<span>{{ T "contents" }}</span>
<span><i class="details-icon fas fa-angle-right"></i></span>
Expand Down

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class Theme {
initToc() {
const $tocCore = document.getElementById('TableOfContents');
if ($tocCore === null) return;
if (document.getElementById('toc-static').getAttribute('kept') || this.util.isTocStatic()) {
if (document.getElementById('toc-static').getAttribute('data-kept') || this.util.isTocStatic()) {
const $tocContentStatic = document.getElementById('toc-content-static');
if ($tocCore.parentElement !== $tocContentStatic) {
$tocCore.parentElement.removeChild($tocCore);
Expand All @@ -419,7 +419,7 @@ class Theme {
const $tocLinkElements = $tocCore.querySelectorAll('a:first-child');
const $tocLiElements = $tocCore.getElementsByTagName('li');
const $headerLinkElements = document.getElementsByClassName('headerLink');
const headerIsFixed = document.body.getAttribute('header-desktop') !== 'normal';
const headerIsFixed = document.body.getAttribute('data-header-desktop') !== 'normal';
const headerHeight = document.getElementById('header-desktop').offsetHeight;
const TOP_SPACING = 20 + (headerIsFixed ? headerHeight : 0);
const minTocTop = $toc.offsetTop;
Expand Down Expand Up @@ -632,8 +632,8 @@ class Theme {

onScroll() {
const $headers = [];
if (document.body.getAttribute('header-desktop') === 'auto') $headers.push(document.getElementById('header-desktop'));
if (document.body.getAttribute('header-mobile') === 'auto') $headers.push(document.getElementById('header-mobile'));
if (document.body.getAttribute('data-header-desktop') === 'auto') $headers.push(document.getElementById('header-desktop'));
if (document.body.getAttribute('data-header-mobile') === 'auto') $headers.push(document.getElementById('header-mobile'));
if (document.getElementById('comments')) {
const $viewComments = document.getElementById('view-comments');
$viewComments.href = `#comments`;
Expand Down