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 development build without server #1554

Merged
merged 1 commit into from
Apr 4, 2025
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
2 changes: 1 addition & 1 deletion content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ This is the <b>main Rust blog</b>. \
<a href="https://www.rust-lang.org/governance/">Rust teams</a> \
use this blog to announce major developments in the world of Rust."""
maintained_by = "the Rust Teams"
see_also_html = """<a href="/inside-rust/index.html">the &quot;Inside Rust&quot; blog</a>"""
see_also_html = """<a href="inside-rust/index.html">the &quot;Inside Rust&quot; blog</a>"""
+++
4 changes: 4 additions & 0 deletions src/blogs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ impl Blog {
&self.path
}

pub(crate) fn path_back_to_root(&self) -> PathBuf {
self.path.components().map(|_| Path::new("../")).collect()
}

pub(crate) fn posts(&self) -> &[Post] {
&self.pages
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl Generator {
let data = json!({
"title": blog.index_title(),
"section": blog,
"root": blog.path_back_to_root(),
});
let path = blog.path().join("index.html");
self.render_template(&path, "index.html", data)?;
Expand All @@ -153,6 +154,7 @@ impl Generator {
"title": format!("{} | {}", post.title, blog.title()),
"section": blog,
"page": post,
"root": blog.path_back_to_root().join("../../../"),
});

let path = path.join(filename);
Expand Down
18 changes: 9 additions & 9 deletions templates/footer.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro footer() -%}
{% macro footer(root) -%}
<footer>
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
<div class="row">
Expand All @@ -22,16 +22,16 @@ <h4>Terms and policies</h4>
<div class="four columns mt3 mt0-l">
<h4>Social</h4>
<div class="flex flex-row flex-wrap">
<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>
<a href="https://twitter.com/rustlang" target="_blank" rel="noopener" alt="twitter link"><img src="/images/twitter.svg" alt="twitter logo" title="Twitter"/></a>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
</div>
<h4 class="mt4 mb3">RSS</h4>
<ul>
<li><a href="/feed.xml">Main Blog</a></li>
<li><a href="/inside-rust/feed.xml">"Inside Rust" Blog</a></li>
<li><a href="{{ root }}feed.xml">Main Blog</a></li>
<li><a href="{{ root }}inside-rust/feed.xml">"Inside Rust" Blog</a></li>
</ul>
</div>

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

<!-- scripts -->
<script src="/scripts/highlight.js"></script>
<script src="{{ root }}scripts/highlight.js"></script>
{% endmacro %}
26 changes: 13 additions & 13 deletions templates/headers.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro headers(title, section) -%}
{% macro headers(title, section, root) -%}
<!-- Twitter card -->
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@rustlang">
Expand All @@ -15,29 +15,29 @@
<meta property="og:locale" content="en_US" />

<!-- styles -->
<link rel="stylesheet" href="/styles/vendor.css"/>
<link rel="stylesheet" href="/styles/fonts.css"/>
<link rel="stylesheet" href="/styles/app.css"/>
<link rel="stylesheet" href="/styles/highlight.css"/>
<link rel="stylesheet" href="{{ root }}styles/vendor.css"/>
<link rel="stylesheet" href="{{ root }}styles/fonts.css"/>
<link rel="stylesheet" href="{{ root }}styles/app.css"/>
<link rel="stylesheet" href="{{ root }}styles/highlight.css"/>

<!-- stylesheet for user agents without js -->
<noscript>
<link rel="stylesheet" href="/styles/noscript.css">
<link rel="stylesheet" href="{{ root }}styles/noscript.css">
</noscript>

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

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

<!-- theme switcher -->
<script src="/scripts/theme-switch.js"></script>
<script src="{{ root }}scripts/theme-switch.js"></script>
{% endmacro %}
6 changes: 3 additions & 3 deletions templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<title>{{ macros::escape_hbs(input=title) }}</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="description" content="Empowering everyone to build reliable and efficient software.">
{{ headers::headers(title=title, section=section) | indent(prefix=" ", blank=true) }}
{{ headers::headers(title=title, section=section, root=root) | indent(prefix=" ", blank=true) }}
</head>
<body>
{{ nav::nav(section=section) | indent(prefix=" ", blank=true) }}
{{ nav::nav(section=section, root=root) | indent(prefix=" ", blank=true) }}
{%- block page %}{% endblock page %}
{{ footer::footer() | indent(prefix=" ", blank=true) }}
{{ footer::footer(root=root) | indent(prefix=" ", blank=true) }}
</body>
</html>
8 changes: 4 additions & 4 deletions templates/nav.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% macro nav(section) -%}
{% macro nav(section, root) -%}
<nav class="flex flex-row justify-center justify-end-l items-center flex-wrap ph2 pl3-ns pr4-ns">
<div class="brand flex-auto w-100 w-auto-l self-start tc tl-l">
<a href="/{{ section.path }}">
<img class="v-mid ml0-l rust-logo" alt="Rust Logo" src="/images/rust-logo-blk.svg">
<a href="{{ root }}{{ section.path }}">
<img class="v-mid ml0-l rust-logo" alt="Rust Logo" src="{{ root }}images/rust-logo-blk.svg">
<span class="dib ml1 ml0-l">{{ section.title }}</span>
</a>
</div>
Expand All @@ -21,7 +21,7 @@
<li class="theme-item" onclick="changeThemeTo('system');">System</li>
</ul>
</button>
<script src="/scripts/theme-switch-post.js"></script>
<script src="{{ root }}scripts/theme-switch-post.js"></script>
</ul>
</nav>
{% endmacro %}