Skip to content

Commit 13cefbf

Browse files
authored
Fix development build without server (#1554)
This is basically a revert of f057363
1 parent 476bc93 commit 13cefbf

File tree

7 files changed

+36
-30
lines changed

7 files changed

+36
-30
lines changed

Diff for: content/_index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ This is the <b>main Rust blog</b>. \
77
<a href="https://www.rust-lang.org/governance/">Rust teams</a> \
88
use this blog to announce major developments in the world of Rust."""
99
maintained_by = "the Rust Teams"
10-
see_also_html = """<a href="/inside-rust/index.html">the &quot;Inside Rust&quot; blog</a>"""
10+
see_also_html = """<a href="inside-rust/index.html">the &quot;Inside Rust&quot; blog</a>"""
1111
+++

Diff for: src/blogs.rs

+4
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ impl Blog {
110110
&self.path
111111
}
112112

113+
pub(crate) fn path_back_to_root(&self) -> PathBuf {
114+
self.path.components().map(|_| Path::new("../")).collect()
115+
}
116+
113117
pub(crate) fn posts(&self) -> &[Post] {
114118
&self.pages
115119
}

Diff for: src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ impl Generator {
131131
let data = json!({
132132
"title": blog.index_title(),
133133
"section": blog,
134+
"root": blog.path_back_to_root(),
134135
});
135136
let path = blog.path().join("index.html");
136137
self.render_template(&path, "index.html", data)?;
@@ -153,6 +154,7 @@ impl Generator {
153154
"title": format!("{} | {}", post.title, blog.title()),
154155
"section": blog,
155156
"page": post,
157+
"root": blog.path_back_to_root().join("../../../"),
156158
});
157159

158160
let path = path.join(filename);

Diff for: templates/footer.html

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% macro footer() -%}
1+
{% macro footer(root) -%}
22
<footer>
33
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
44
<div class="row">
@@ -22,16 +22,16 @@ <h4>Terms and policies</h4>
2222
<div class="four columns mt3 mt0-l">
2323
<h4>Social</h4>
2424
<div class="flex flex-row flex-wrap">
25-
<a rel="me" href="https://social.rust-lang.org/@rust" target="_blank" rel="noopener" alt="mastodon link"><img src="/images/mastodon.svg" alt="mastodon logo" title="Mastodon"/></a>
26-
<a href="https://twitter.com/rustlang" target="_blank" rel="noopener" alt="twitter link"><img src="/images/twitter.svg" alt="twitter logo" title="Twitter"/></a>
27-
<a href="https://www.youtube.com/channel/UCaYhcUwRBNscFNUKTjgPFiA" target="_blank" rel="noopener" alt="youtube link"><img style="padding-top: 6px; padding-bottom:6px" src="/images/youtube.svg" alt="youtube logo" title="YouTube"/></a>
28-
<a href="https://discord.gg/rust-lang" target="_blank" rel="noopener" alt="discord link"><img src="/images/discord.svg" alt="discord logo" title="Discord"/></a>
29-
<a href="https://github.com/rust-lang" target="_blank" rel="noopener" alt="github link"><img src="/images/github.svg" alt="github logo" title="GitHub"/></a>
25+
<a rel="me" href="https://social.rust-lang.org/@rust" target="_blank" rel="noopener" alt="mastodon link"><img src="{{ root }}images/mastodon.svg" alt="mastodon logo" title="Mastodon"/></a>
26+
<a href="https://twitter.com/rustlang" target="_blank" rel="noopener" alt="twitter link"><img src="{{ root }}images/twitter.svg" alt="twitter logo" title="Twitter"/></a>
27+
<a href="https://www.youtube.com/channel/UCaYhcUwRBNscFNUKTjgPFiA" target="_blank" rel="noopener" alt="youtube link"><img style="padding-top: 6px; padding-bottom:6px" src="{{ root }}images/youtube.svg" alt="youtube logo" title="YouTube"/></a>
28+
<a href="https://discord.gg/rust-lang" target="_blank" rel="noopener" alt="discord link"><img src="{{ root }}images/discord.svg" alt="discord logo" title="Discord"/></a>
29+
<a href="https://github.com/rust-lang" target="_blank" rel="noopener" alt="github link"><img src="{{ root }}images/github.svg" alt="github logo" title="GitHub"/></a>
3030
</div>
3131
<h4 class="mt4 mb3">RSS</h4>
3232
<ul>
33-
<li><a href="/feed.xml">Main Blog</a></li>
34-
<li><a href="/inside-rust/feed.xml">"Inside Rust" Blog</a></li>
33+
<li><a href="{{ root }}feed.xml">Main Blog</a></li>
34+
<li><a href="{{ root }}inside-rust/feed.xml">"Inside Rust" Blog</a></li>
3535
</ul>
3636
</div>
3737

@@ -44,5 +44,5 @@ <h4 class="mt4 mb3">RSS</h4>
4444
</footer>
4545

4646
<!-- scripts -->
47-
<script src="/scripts/highlight.js"></script>
47+
<script src="{{ root }}scripts/highlight.js"></script>
4848
{% endmacro %}

Diff for: templates/headers.html

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% macro headers(title, section) -%}
1+
{% macro headers(title, section, root) -%}
22
<!-- Twitter card -->
33
<meta name="twitter:card" content="summary">
44
<meta name="twitter:site" content="@rustlang">
@@ -15,29 +15,29 @@
1515
<meta property="og:locale" content="en_US" />
1616

1717
<!-- styles -->
18-
<link rel="stylesheet" href="/styles/vendor.css"/>
19-
<link rel="stylesheet" href="/styles/fonts.css"/>
20-
<link rel="stylesheet" href="/styles/app.css"/>
21-
<link rel="stylesheet" href="/styles/highlight.css"/>
18+
<link rel="stylesheet" href="{{ root }}styles/vendor.css"/>
19+
<link rel="stylesheet" href="{{ root }}styles/fonts.css"/>
20+
<link rel="stylesheet" href="{{ root }}styles/app.css"/>
21+
<link rel="stylesheet" href="{{ root }}styles/highlight.css"/>
2222

2323
<!-- stylesheet for user agents without js -->
2424
<noscript>
25-
<link rel="stylesheet" href="/styles/noscript.css">
25+
<link rel="stylesheet" href="{{ root }}styles/noscript.css">
2626
</noscript>
2727

2828
<!-- favicon -->
29-
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
30-
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
31-
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
32-
<link rel="icon" type="image/svg+xml" href="/images/favicon.svg">
33-
<link rel="manifest" href="/images/site.webmanifest">
34-
<link rel="mask-icon" href="/images/safari-pinned-tab.svg" color="#5bbad5">
29+
<link rel="apple-touch-icon" sizes="180x180" href="{{ root }}images/apple-touch-icon.png">
30+
<link rel="icon" type="image/png" sizes="16x16" href="{{ root }}images/favicon-16x16.png">
31+
<link rel="icon" type="image/png" sizes="32x32" href="{{ root }}images/favicon-32x32.png">
32+
<link rel="icon" type="image/svg+xml" href="{{ root }}images/favicon.svg">
33+
<link rel="manifest" href="{{ root }}images/site.webmanifest">
34+
<link rel="mask-icon" href="{{ root }}images/safari-pinned-tab.svg" color="#5bbad5">
3535
<meta name="msapplication-TileColor" content="#00aba9">
3636
<meta name="theme-color" content="#ffffff">
3737

3838
<!-- atom -->
3939
<link type="application/atom+xml" rel="alternate" href="https://blog.rust-lang.org/{{ section.path }}feed.xml" title="{{ section.title }}" />
4040

4141
<!-- theme switcher -->
42-
<script src="/scripts/theme-switch.js"></script>
42+
<script src="{{ root }}scripts/theme-switch.js"></script>
4343
{% endmacro %}

Diff for: templates/layout.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
<title>{{ macros::escape_hbs(input=title) }}</title>
1010
<meta name="viewport" content="width=device-width,initial-scale=1.0">
1111
<meta name="description" content="Empowering everyone to build reliable and efficient software.">
12-
{{ headers::headers(title=title, section=section) | indent(prefix=" ", blank=true) }}
12+
{{ headers::headers(title=title, section=section, root=root) | indent(prefix=" ", blank=true) }}
1313
</head>
1414
<body>
15-
{{ nav::nav(section=section) | indent(prefix=" ", blank=true) }}
15+
{{ nav::nav(section=section, root=root) | indent(prefix=" ", blank=true) }}
1616
{%- block page %}{% endblock page %}
17-
{{ footer::footer() | indent(prefix=" ", blank=true) }}
17+
{{ footer::footer(root=root) | indent(prefix=" ", blank=true) }}
1818
</body>
1919
</html>

Diff for: templates/nav.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
{% macro nav(section) -%}
1+
{% macro nav(section, root) -%}
22
<nav class="flex flex-row justify-center justify-end-l items-center flex-wrap ph2 pl3-ns pr4-ns">
33
<div class="brand flex-auto w-100 w-auto-l self-start tc tl-l">
4-
<a href="/{{ section.path }}">
5-
<img class="v-mid ml0-l rust-logo" alt="Rust Logo" src="/images/rust-logo-blk.svg">
4+
<a href="{{ root }}{{ section.path }}">
5+
<img class="v-mid ml0-l rust-logo" alt="Rust Logo" src="{{ root }}images/rust-logo-blk.svg">
66
<span class="dib ml1 ml0-l">{{ section.title }}</span>
77
</a>
88
</div>
@@ -21,7 +21,7 @@
2121
<li class="theme-item" onclick="changeThemeTo('system');">System</li>
2222
</ul>
2323
</button>
24-
<script src="/scripts/theme-switch-post.js"></script>
24+
<script src="{{ root }}scripts/theme-switch-post.js"></script>
2525
</ul>
2626
</nav>
2727
{% endmacro %}

0 commit comments

Comments
 (0)