-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Feat: add article expiration reminder support (#51)
- Loading branch information
Showing
9 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{{- $params := .Scratch.Get "params" -}} | ||
{{- $expirationReminder := $params.expirationReminder | default dict -}} | ||
|
||
{{- if $expirationReminder.enable -}} | ||
{{- $daysAgo := div (sub now.Unix .Lastmod.Unix) 86400 }} | ||
{{- $reminderThreshold := $expirationReminder.reminder | default 90 }} | ||
{{- $warningThreshold := $expirationReminder.warning | default 180 }} | ||
{{- $updateTime := .Lastmod }} | ||
|
||
{{- if gt $daysAgo $reminderThreshold -}} | ||
{{- $type := "note" -}} | ||
{{- $icon := "fa-pencil-alt" -}} | ||
{{- if gt $daysAgo $warningThreshold -}} | ||
{{- $type = "warning" -}} | ||
{{- $icon = "fa-exclamation-triangle" -}} | ||
{{- /* If the article expires, close the comment or not */ -}} | ||
{{- if $expirationReminder.closeComment -}} | ||
{{- .Scratch.Set "comment" dict -}} | ||
{{- end -}} | ||
{{- end -}} | ||
<div class="details admonition {{ $type }} open"> | ||
<div class="details-summary admonition-title"> | ||
<i class="icon fas {{ $icon }} fa-fw"></i>{{ T $type }}<i class="details-icon fas fa-angle-right fa-fw"></i> | ||
</div> | ||
<div class="details-content"> | ||
<div class="admonition-content"> | ||
{{- with .Site.Params.dateformat | default "2006-01-02" | $updateTime.Format -}} | ||
{{- dict "Date" . | T "expirationReminder" -}} | ||
{{- end -}} | ||
</div> | ||
</div> | ||
</div> | ||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters