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

[FIX] Keep the article in the middle when toc is off #77

Merged
merged 2 commits into from
May 27, 2021
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
7 changes: 6 additions & 1 deletion assets/css/_page/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
max-width: initial;
width: 60%;
margin: 0 auto;
[pageStyle=wide] & {
[pageStyle=wide][autoTOC=true] & {
margin-left: 10%;
margin-right: auto;
width: 70%;
}
[pageStyle=wide][autoTOC=false] & {
width: 70%;
margin-left: 15%;
margin-right: 15%;
}
[header-desktop] & {
padding-top: $header-height;
}
Expand Down
1 change: 1 addition & 0 deletions assets/css/_partial/_single/_showcase.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ $showcase-hover-color-dark: #ffffff;
$showcase-hover-color-black: #ffffff;

.showcase-box {
width: 48%;
height: 370px;
margin: 1% 1% 0% 0%;
display: inline-block !important;
Expand Down
14 changes: 7 additions & 7 deletions exampleSite/content/posts/tests/showcase-tests/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ description: "Showcase shortcode test"
categories: [Tests]
hiddenFromHomePage: true
toc: false
pageStyle: normal
pageStyle: wide
---

<!--more-->

{{< showcase title="Theme Documentation - Basics" summary="Discover what the Hugo - DoIt theme is all about and the core-concepts behind it." image="/theme-documentation-basics/featured-image.webp" link="/theme-documentation-basics" >}}
{{< showcase title="Theme Documentation - Basics" summary="Discover what the Hugo - DoIt theme is all about and the core-concepts behind it." image="/theme-documentation-basics/featured-image.webp" link="/theme-documentation-basics" column="3" >}}

{{< showcase title="Theme Documentation - Content" summary="Find out how to create and organize your content quickly and intuitively in DoIt theme." image="/theme-documentation-content/featured-image.webp" link="/theme-documentation-content" >}}
{{< showcase title="Theme Documentation - Content" summary="Find out how to create and organize your content quickly and intuitively in DoIt theme." image="/theme-documentation-content/featured-image.webp" link="/theme-documentation-content" column="3" >}}

{{< showcase title="Theme Documentation - Built-in Shortcodes" summary="Hugo provides multiple built-in shortcodes for author convenience and to keep your markdown content clean." image="/theme-documentation-built-in-shortcodes/featured-image.webp" link="/theme-documentation-built-in-shortcodes" >}}
{{< showcase title="Theme Documentation - Built-in Shortcodes" summary="Hugo provides multiple built-in shortcodes for author convenience and to keep your markdown content clean." image="/theme-documentation-built-in-shortcodes/featured-image.webp" link="/theme-documentation-built-in-shortcodes" column="3" >}}

{{< showcase title="Theme Documentation - Extended Shortcodes" summary="DoIt theme provides multiple shortcodes on top of built-in ones in Hugo." image="/theme-documentation-extended-shortcodes/featured-image.webp" link="/theme-documentation-extended-shortcodes" >}}
{{< showcase title="Theme Documentation - Extended Shortcodes" summary="DoIt theme provides multiple shortcodes on top of built-in ones in Hugo." image="/theme-documentation-extended-shortcodes/featured-image.webp" link="/theme-documentation-extended-shortcodes" column="3" >}}

{{< showcase title="Seal!" summary="Awww" image="https://i.pinimg.com/originals/b8/75/9a/b8759a1b9575a1f938a16f7b5c5287fe.jpg" link="https://i.pinimg.com/originals/b8/75/9a/b8759a1b9575a1f938a16f7b5c5287fe.jpg" >}}
{{< showcase title="Seal!" summary="Awww" image="https://i.pinimg.com/originals/b8/75/9a/b8759a1b9575a1f938a16f7b5c5287fe.jpg" link="https://i.pinimg.com/originals/b8/75/9a/b8759a1b9575a1f938a16f7b5c5287fe.jpg" column="3" >}}

{{< showcase "Cat!" "Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ " "https://img.webmd.com/dtmcms/live/webmd/consumer_assets/site_images/article_thumbnails/other/cat_relaxing_on_patio_other/1800x1200_cat_relaxing_on_patio_other.jpg" "https://img.webmd.com/dtmcms/live/webmd/consumer_assets/site_images/article_thumbnails/other/cat_relaxing_on_patio_other/1800x1200_cat_relaxing_on_patio_other.jpg" >}}
{{< showcase "Cat!" "Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ Miaow~ " "https://img.webmd.com/dtmcms/live/webmd/consumer_assets/site_images/article_thumbnails/other/cat_relaxing_on_patio_other/1800x1200_cat_relaxing_on_patio_other.jpg" "https://img.webmd.com/dtmcms/live/webmd/consumer_assets/site_images/article_thumbnails/other/cat_relaxing_on_patio_other/1800x1200_cat_relaxing_on_patio_other.jpg" "3" >}}
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,10 @@ The `showcase` shortcode has the following named parameters:

The url to your project page.

* **column** *[optional]* (**fifth** positional parameter)

This parameter defines how many showcases in each row. The default value is 2, which means there will have two showcases in each row. You can change it to 1, 2 or 3.

Example `showcase` input:

```markdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,10 @@ console.log('Just DoIt!');

项目主页的链接.

* **column** *[optional]* (**fifth** positional parameter)

这个参数定义一行显示几个 `showcase`. 默认的值是 2, 默认一行显示两个 `showcase`. 你可以将它改为 1, 2 或 3.

一个 `showcase` 示例:

```markdown
Expand Down

Large diffs are not rendered by default.

29 changes: 21 additions & 8 deletions layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,38 @@

{{- $toc := $params.toc -}}
{{- if eq $toc true -}}
{{- $toc = .Site.Params.page.toc | default dict -}}
{{- $toc = .Site.Params.page.toc | default dict -}}
{{- else if eq $toc false -}}
{{- $toc = dict "enable" false -}}
{{- $toc = dict "enable" false -}}
{{- end -}}



{{- /* Auto TOC */ -}}
{{- if ne $toc.enable false -}}
<div class="toc" id="toc-auto">
<h2 class="toc-title">{{ T "contents" }}</h2>
<div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}" id="toc-content-auto"></div>
</div>
<div class="toc" id="toc-auto">
<h2 class="toc-title">{{ T "contents" }}</h2>
<div class="toc-content{{ if eq $toc.auto false }} always-active{{ end }}" id="toc-content-auto"></div>
</div>
{{- end -}}

{{- /* Page Style */ -}}
{{- if eq $params.pageStyle "wide" -}}
<script>document.body.setAttribute("pageStyle", "wide")</script>
{{- else -}}
<script>document.body.setAttribute("pageStyle", "normal")</script>
{{- end -}}

{{- /* TOC Style */ -}}
{{- if eq $toc.enable true -}}
{{- if eq $toc.keepStatic true -}}
<script>document.body.setAttribute("autoTOC", "false")</script>
{{- else if eq $toc.keepStatic false -}}
<script>document.body.setAttribute("autoTOC", "true")</script>
{{- end -}}
{{- else if eq $toc.enable false -}}
<script>document.body.setAttribute("autoTOC", "false")</script>
{{- end -}}

<article class="page single">
{{- /* Title */ -}}
<h1 class="single-title animate__animated animate__flipInX">{{ .Title }}</h1>
Expand Down
2 changes: 2 additions & 0 deletions layouts/shortcodes/showcase.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
{{- $summary = .Get "summary" -}}
{{- $link = .Get "link" -}}
{{- $image = .Get "image" -}}
{{- $column = .Get "column" -}}
{{- else -}}
{{- $title = .Get 0 -}}
{{- $summary = .Get 1 -}}
{{- $image = .Get 2 -}}
{{- $link = .Get 3 -}}
{{- $column = .Get 4 -}}
{{ end }}
<div class="showcase-box column-{{ $column }}">
<div class="showcase-image">
Expand Down