Add page title filter
I want the home page to use just `title` as the page title, but I want other pages to add the site name to the page title. This filter does that and spits out the final title.
This commit is contained in:
parent
960966dcc4
commit
e901a8360f
2 changed files with 27 additions and 18 deletions
|
|
@ -20,6 +20,13 @@ module.exports = function(eleventyConfig) {
|
|||
"node_modules/simpledotcss/simple.css": "css/simple.css",
|
||||
});
|
||||
|
||||
eleventyConfig.addFilter("buildPageTitle", function(title) {
|
||||
if (this.page.url === '/') {
|
||||
return title;
|
||||
} else {
|
||||
return title + ' ⇢ Devon.LoL 😆';
|
||||
}
|
||||
});
|
||||
eleventyConfig.addFilter("stringToDate", function(value) {
|
||||
return new Date(value);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,21 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="/css/simple.css">
|
||||
<link rel="stylesheet" href="/css/theme.css">
|
||||
<link rel="alternate" type="application/rss+xml" title="RSS"
|
||||
href="https://devon.lol/feed.xml">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||
<link rel="manifest" href="/site.webmanifest">
|
||||
<title>{{ title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="/" class="logo"><img src="/images/logo.png" alt="Devon.LOL"></a>
|
||||
{{ content | safe }}
|
||||
</body>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="/css/simple.css">
|
||||
<link rel="stylesheet" href="/css/theme.css">
|
||||
<link rel="alternate" type="application/rss+xml" title="RSS" href="https://devon.lol/feed.xml">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||
<link rel="manifest" href="/site.webmanifest">
|
||||
<title>{{ title | buildPageTitle }}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a href="/" class="logo"><img src="/images/logo.png" alt="Devon.LOL"></a>
|
||||
{{ content | safe }}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue