Skip to content

Commit 5dfe40c

Browse files
authored
Add banner (#373)
1 parent a319319 commit 5dfe40c

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

config.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ footnotereturnlinkcontents = "↩"
6868
description = "Write HTML, PDF, ePub, and Kindle books with R Markdown"
6969
footer = "© [RStudio, PBC](https://www.rstudio.com) 2016 -- 2020"
7070

71+
[params.announcement]
72+
enabled = true
73+
header = "⚠️ Important"
74+
message = """The bookdown.org hosting service is being decommissioned.<br> \
75+
<a href="https://posit.co/blog/bookdown-org-sunset">See the announcement blog post →</a>"""
76+
7177
[markup]
7278
[markup.goldmark]
7379
[markup.goldmark.renderer]

layouts/partials/announcement.html

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{{/*
2+
Site-wide announcement banner partial
3+
4+
Displays a configurable announcement banner at the top of all pages.
5+
Banner content and settings are configured in config.toml under [params.announcement]
6+
7+
To disable: Set enabled = false in config.toml
8+
To update message: Edit the message field in config.toml
9+
10+
Created: 2025-01-04 for bookdown.org sunset announcement
11+
*/}}
12+
{{ if .Site.Params.announcement.enabled }}
13+
<style>
14+
.announcement-banner-wrapper {
15+
background: linear-gradient(135deg, #f0ad4e 0%, #ec971f 100%);
16+
width: 100%;
17+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
18+
margin-bottom: 1em;
19+
}
20+
.announcement-banner {
21+
max-width: 1100px;
22+
margin: 0 auto;
23+
padding: 0.75em 1.25em;
24+
color: #000;
25+
text-align: left;
26+
line-height: 1.4;
27+
font-size: 0.95em;
28+
}
29+
.announcement-banner-header {
30+
font-weight: bold;
31+
font-size: 1em;
32+
margin-bottom: 0.3em;
33+
display: block;
34+
}
35+
.announcement-banner a {
36+
color: #1a1a1a;
37+
text-decoration: underline;
38+
font-weight: bold;
39+
text-decoration-thickness: 2px;
40+
text-underline-offset: 2px;
41+
display: inline-block;
42+
margin-top: 0.4em;
43+
}
44+
.announcement-banner a:hover {
45+
color: #000;
46+
text-decoration-thickness: 3px;
47+
}
48+
</style>
49+
50+
<div class="announcement-banner-wrapper">
51+
<div class="announcement-banner">
52+
{{ with .Site.Params.announcement.header }}
53+
<span class="announcement-banner-header">{{ . | safeHTML }}</span>
54+
{{ end }}
55+
{{ .Site.Params.announcement.message | safeHTML }}
56+
</div>
57+
</div>
58+
{{ end }}

layouts/partials/header.html

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{{/*
2+
Project-level override of themes/hugo-xmin/layouts/partials/header.html
3+
4+
This file is a copy of the theme's header with ONE addition:
5+
- Line 40: {{ partial "announcement.html" . }} - Injects site-wide announcement banner
6+
7+
The announcement banner is configured in config.toml under [params.announcement]
8+
9+
Created: 2025-01-04 for bookdown.org sunset announcement
10+
*/}}
11+
<!DOCTYPE html>
12+
<html lang="{{ .Site.LanguageCode }}">
13+
<head>
14+
<meta charset="utf-8">
15+
<meta name="viewport" content="width=device-width, initial-scale=1">
16+
<title>{{ .Title }} | {{ .Site.Title }}</title>
17+
<meta name="twitter:card" content="summary" />
18+
<meta name="twitter:title" content="bookdown: Authoring Books and Technical Documents with R Markdown" />
19+
<meta name="twitter:description" content="The platform bookdown.org is provided by RStudio for authors to publish books online for free. The bookdown package is an open-source R package that facilitates writing books and long-form articles/reports with R Markdown." />
20+
<meta name="twitter:image" content="https://bookdown.org/yihui/bookdown/images/logo.png" />
21+
<meta property="og:image" content="https://bookdown.org/yihui/bookdown/images/logo.png" />
22+
<link rel="icon" type="image/png" href="{{ "/images/favicon.png" | relURL }}" />
23+
<link rel="stylesheet" href="{{ "/css/style.css" | relURL }}" />
24+
<link rel="stylesheet" href="{{ "/css/fonts.css" | relURL }}" />
25+
</head>
26+
27+
<body>
28+
<nav class="menu">
29+
{{ partial "icons.html" . }}
30+
<ul>
31+
{{ range .Site.Menus.logo }}
32+
<li class="icon left">
33+
<a href="{{ .URL | relURL }}"><img src="{{ relURL .Pre }}" alt="{{ .Name }}" title="{{ .Name }}" /></a>
34+
</li>
35+
{{ end }}
36+
{{ range .Site.Menus.main }}
37+
<li{{ if .Identifier }} class="optional"{{ end }}>
38+
<a href="{{ .URL | relURL }}"{{ if eq .URL $.RelPermalink }} class="active"{{ end }}>{{ .Name }}</a>
39+
</li>
40+
{{ end }}
41+
{{ range .Site.Menus.icons }}
42+
<li class="icon right">
43+
<a href="{{ .URL | relURL }}"><svg viewBox="0 0 16 16"><use xlink:href="#icon-{{ .Post }}"></use></svg></a>
44+
</li>
45+
{{ end }}
46+
</ul>
47+
</nav>
48+
{{ partial "announcement.html" . }}

0 commit comments

Comments
 (0)