![]() |
VOOZH | about |
We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.
Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.
Follow TNS on your favorite social media networks.
Become a TNS follower on LinkedIn.
Check out the latest featured and trending stories while you wait for your first TNS newsletter.
module.exports = function(eleventyConfig) {
// Return your Object options:
return {
dir: {
input: "src",
output: "public"
}
}
};
As we are changing configuration, we need to restart the server. And when we do, nothing will happen until we actually move our source material appropriately and delete the old site. That incudes _includes.
When we make the necessary file moves and run, our kitten (ok, a different kitten) returns. The directory structure, ignoring the modules directory but including the config file, now looks like this:
👁 Image.author-profile-photo-column img
{
display: block;
width: 100%;
aspect-ratio: 1/1;
-o-object-fit: cover;
object-fit: cover;
border-radius: 30px
}
..
header {
background-color: #333;
color: white;
padding: 20px;
h1 {
display: inline-block;
vertical-align: middle;
}
img {
width: 5%;
border-radius: 30px;
display: inline-block;
vertical-align: middle;
float: left;
}
}
..
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy('./src/*.css');
eleventyConfig.addPassthroughCopy('./src/*.png');
return {
dir: {
input: "src",
output: "public"
}
}
};
---
layout: "layout.html"
title: "David's Home Page"
---
Hi there, I like cats!!
Now it should be pointed out that I don’t like cats that much, but I have started this theme so I am condemned to complete it. So I am going to pretend I want to add pages about famous cats.
Our steel thread is that we want to write content in Markdown, and let Eleventy take care of creating the site. While maintaining the site, we don’t want to deal with HTML.
So we’ll make a cats directory in the src, and create our first cat garfield.md into that:
---
layout: "layout.html"
title: "Garfield"
---
Garfield doesn't like Mondays.
If you have the server going (I have it in another Warp tab) you will see Eleventy processing it behind the scenes.
And indeed if we follow the browser path created, we see the following:
OK, that isn’t a picture of Garfield. Also, my nice avatar picture has disappeared from the top left. In addition, we want to link to this page from the index page.
First of all, if we want to show an image of Garfield then we’ll have to refer to it in the front matter. But first we will also need to alter the layout. So lets put the source address of our placekitten into the index.md front matter:
---
layout: "layout.html"
title: "David's Home Page"
catimage: "https://placekitten.com/800/400"
---
Hi there, I like cats!!
And alter our layout to use the new catimage variable:
..
<body>
<header>
<img src="photo-of-me.png">
<h1>{{ title }}</h1>
</header>
<img class="cat" src="{{ catimage }}" alt="A nice cat"> {{content}}
<footer>
<p>© 2024 Nice Cat Page. All rights reserved.</p>
</footer>
</body>
..
---
layout: "layout.html"
title: "Garfield"
catimage: "Garfieldand_friends.png"
---
Garfield doesn't like Mondays.
Almost done. But it won’t work yet. Look at the directory:
👁 Imagemodule.exports = function(eleventyConfig) {
// Return your Object options:
eleventyConfig.addPassthroughCopy('./src/*.css');
eleventyConfig.addPassthroughCopy('./src/*.png');
eleventyConfig.addPassthroughCopy('./src/cats/*.png');
return {
dir: {
input: "src",
output: "public"
}
}
};
---
layout: "layout.html"
title: "Garfield"
catimage: "../Garfieldand_friends.png"
---
Garfield doesn't like Mondays.
And finally we get our cat:
👁 Image..
<header>
<img src="/photo-of-me.png">
<h1>{{ title }}</h1>
</header>
..
---
layout: "layout.html"
title: "Garfield"
catimage: "../Garfieldand_friends.png"
tags: cats
---
Garfield doesn't like Mondays.
We can then loop through our cats and make some form of index:
..
<div class="listcontainer">
<ul>
{% for cat in collections.cats %}
<li>
<a href="/cats/{{ cat.data.title}}">{{ cat.data.title }} </a>
</li>
{% endfor %}
</ul>
</div>
..