-
Notifications
You must be signed in to change notification settings - Fork 2
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
Dejankify header/footer loading #8
Comments
Idea: we could write a build script that precomputes this. That way, the site is fully functional as static files, and a build step can increase performance. |
We could totally write a simple script to just paste the header and footer into each output file.
<!DOCTYPE html>
<html lang="en">
<head>
<title> {{ title }} </title>
OUR META AND CSS STUFF
</head>
<body>
<header> OUR NAV BAR STUFF </header>
<h1> {{ heading }} </h1>
<main> {{ content | safe }} </main>
<footer> OUR FOOTER STUFF </footer>
</body>
</html>
---
layout: base.njk {# Specifies if and what "template" to use #}
title: Husky Satellite {# custom "title" attribute, which base.njk reads and puts in the head #}
heading: The Husky Satellite Lab is taking the University of Washington to space {# custom "heading" attribute #}
---
<p>Actual content html goes here.</p>
<div class="sponsors">
{% for sponsor in sponsors %} {# automatically reads data form src/_data/sponsors.json #}
<p>Hello, I'm {{ sponsor.name }} and here's my image:</p>
<img src="images/{{ sponsor.image }}">
{% endfor %}
</div class = "sponsors"> In this case, Then we add a simple config option to eleventyConfig.addPassthroughCopy("src/css/");
eleventyConfig.addPassthroughCopy("src/images"); And that's it. Just run I'm currently working on making an eleventy-built version of this site, though it might take me a while. |
Ok, I finished making an experimental prototype version of this website that works without javascript: Note: I did a major overhaul of the CSS, so some things still aren't correct. |
Currently, the header & footer are injected using
document.write()
which is not a best practice due to blocking page load until a round trip completes.It would be good to find a way to handle page loads without this hackery.
I would really love it if we did it in a way where:
Is this possible maybe? I'm not sure.
The text was updated successfully, but these errors were encountered: