Compare commits

...

3 Commits

9 changed files with 70 additions and 181 deletions

View File

@ -48,8 +48,6 @@ module.exports = function (eleventyConfig) {
return str.split('/').map(part => encodeURI(part)).join('/')
});
// TODO: this appears to potentially be dependent on rendering order
// TODO: actually add to the post ui
eleventyConfig.addFilter("related", function(obj) {
const post = this.ctx;
const posts = this.ctx.collections.posts.map(post => post.data);
@ -64,13 +62,14 @@ module.exports = function (eleventyConfig) {
serializer: (doc) => [doc.title, doc.description],
weights: [10, 10],
})(post, posts).map(result => {
console.log(result.document);
return {
relative: result.relative + tagScore(post, result.document),
document: result.document
}
});
return results.filter(result => result.relative > 0.0).slice(0,3);
return results.filter(result => result.relative > 0.2).sort((a, b) => a.relative - b.relative).reverse().slice(0,3);
});
eleventyConfig.addCollection('posts', collection => {

View File

@ -3,8 +3,8 @@
"version": "1.0.0",
"description": "",
"scripts": {
"build": "rm -rf www && eleventy",
"serve": "rm -rf www && eleventy --serve",
"build": "ELEVENTY_ENV=prod rm -rf www && eleventy",
"serve": "ELEVENTY_ENV=dev rm -rf www && eleventy --serve",
"update": "git pull && npm i && npm run build"
},
"dependencies": {

9
src/_data/env.js Normal file
View File

@ -0,0 +1,9 @@
module.exports = function() {
return {
environment: {
environment: process.env.ELEVENTY_ENV || "dev",
isProd: process.env.ELEVENTY_ENV == "prod",
isDev: (process.env.ELEVENTY_ENV || "dev") == "dev"
}
};
}

View File

@ -27,8 +27,9 @@
<link rel="shortcut icon" href="/favicon.ico">
<link rel="alternate" type="application/rss+xml" href="/feed.xml" />
<script async src="https://umami.crimew.gay/script.js" data-website-id="fa7a72e7-acbc-488d-beb2-213886be0262"></script>
{% if env.environment.isProd %}
<script async src="https://umami.crimew.gay/script.js" data-website-id="fa7a72e7-acbc-488d-beb2-213886be0262"></script>
{% endif %}
</head>
<body>
<header id="site_header">

View File

@ -17,8 +17,8 @@ subhead: blog
<span class="readtime">{{ content | timeToRead }} to read</span>
<span class="middot"></span>
<span>by <span class="author by" id="author">{{ site.name }}</span></span>
<span class="middot"></span>
{% if tags %}
<span class="middot"></span>
<span>in
{% for tag in tags %}
<span class="tag"><a href="/posts/tagged/{{ tag | slugify }}/">{{ tag }}</a></span>{% if not loop.last %}, {% endif %}
@ -47,4 +47,35 @@ subhead: blog
</div>
</a>
</article>
{% for rel in "" | related %}
{% if loop.first %}
<div class="related">
<h3>related posts</h3>
<ul>
{% endif %}
<li class="list-entry">
<!-- rank {{ rel.relative }} -->
<a href="{{ rel.document.page.url }}"><h4>{{ rel.document.title }}</h4></a>
<div class="byline">
<time datetime="{{ rel.document.page.date | date_to_datetime }}">{{ rel.document.page.date | date_formatted }}</time>
{% if rel.document.changed_date %}
<small class="updated">(updated <time datetime="{{ rel.document.changed_date | date_to_datetime }}">{{ rel.document.changed_date | date_formatted }}</time>)</small>
{% endif %}
<span class="middot"></span>
<span class="readtime">{{ rel.document.content | timeToRead }} to read</span>
<span class="middot"></span>
<span>by <span class="author by" id="author">{{ site.name }}</span></span>
{% if rel.document.tags %}
<span class="middot"></span>
<span>in
{% for tag in rel.document.tags %}
<span class="tag"><a href="/posts/tagged/{{ tag | slugify }}/">{{ tag }}</a></span>{% if not loop.last %}, {% endif %}
{% endfor %}
</span>
{% endif %}
</div>
<span class="lead"><strong>{{ rel.document.description }}</strong></span>
</li>
{% if loop.last %}</ul></div>{% endif %}
{% endfor %}
{% endblock %}

View File

@ -79,6 +79,26 @@ time,
border-bottom: 1px dotted rgb(219, 103, 167);
}
.related {
margin-top: 18px;
border-top: 1px dotted rgb(219, 103, 167);
h3 {
margin-top: 4px;
margin-bottom: 0;
}
ul {
margin-top: 4px;
padding-left: 0;
h4 {
margin-top: 4px;
margin-bottom: 0;
}
}
}
.article_header>h1,
.page_header>h1 {
margin: 0.1rem;

View File

@ -22,8 +22,8 @@ permalink: /posts/{% if pagination.pageNumber > 0 %}page/{{ pagination.pageNumbe
<span class="readtime">{{ entry.content | timeToRead }} to read</span>
<span class="middot"></span>
<span>by <span class="author by" id="author">{{ site.name }}</span></span>
<span class="middot"></span>
{% if entry.data.tags %}
<span class="middot"></span>
<span>in
{% for tag in entry.data.tags %}
<span class="tag"><a href="/posts/tagged/{{ tag | slugify }}/">{{ tag }}</a></span>{% if not loop.last %}, {% endif %}

View File

@ -1,171 +0,0 @@
html {
background-color: rgb(236, 169, 203);
color: rgb(92, 53, 124);
}
a, .like-a {
color: rgb(255, 0, 140);
}
.like-a {
text-decoration: underline;
}
a.active,
li.lavender-webring-curr-site > a {
color: rgb(195, 0, 255);
}
#site_header {
padding-bottom: 5px;
border-bottom: 1px solid rgb(255, 0, 140);
}
footer {
padding-top: 5px;
}
.footer-kitten {
height: 88px;
border-bottom: 1px solid rgb(255, 0, 140);
margin-bottom: 5px;
}
.footer-kitten > img {
height: 88px;
}
footer,
#site_header,
.lavender-webring-container {
text-align: center;
}
.list-entry {
list-style-type: none;
}
.list-entry h2 {
margin-bottom: 0;
}
#content {
max-width: 900px;
margin-left: auto;
margin-right: auto;
padding-top: 2em;
padding-bottom: 2em;
}
.byline {
font-size: 0.75rem;
}
.middot::after {
content: '\00B7';
display: inline-block;
}
time,
.author,
.updated {
font-weight: bold;
}
.article_header,
.page_header {
padding-bottom: 4px;
border-bottom: 1px dotted rgb(219, 103, 167);
}
.article_header > h1,
.page_header > h1 {
margin: 0.1rem;
}
img {
max-width: 75%;
}
.tag {
font-weight: bold;
}
.banner-link {
color: inherit;
text-decoration: inherit;
}
.kofi-banner, .content-warnings {
border-radius: 8px;
padding: 4px;
border: 2px solid rgb(255, 0, 140);
background-color: rgba(221, 116, 174, 0.211);
font-size: 1.1rem;
}
.content-warnings {
margin-top: 16px;
margin-bottom: 16px;
width: fit-content;
}
.content-warnings > p {
margin: 0;
}
.greentext {
color: #789922;
}
.lavender-webring-container {
all: unset;
display: flex;
flex-direction: column;
padding: 1em;
font-size: 1.125rem;
}
.lavender-webring-description {
margin-block-end: 0.5em;
}
.lavender-webring-site-links {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
list-style: none;
margin: 0;
padding: 0;
}
.lavender-webring-prev-site a::before {
content: "←";
margin-inline-end: 1ch;
}
.lavender-webring-next-site a::after {
content: "→";
margin-inline-start: 1ch;
}
.sleepy-zone-webring-container {
all: unset;
display: flex;
flex-direction: column;
padding: 1em;
font-size: 1.125rem;
}
.sleepy-zone-webring-description {
margin-block-end: 0.5em;
}
.sleepy-zone-webring-site-links {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
list-style: none;
margin: 0;
padding: 0;
}
.sleepy-zone-webring-prev-site a::before {
content: "←";
margin-inline-end: 1ch;
}
.sleepy-zone-webring-next-site a::after {
content: "→";
margin-inline-start: 1ch;
}

View File

@ -29,8 +29,8 @@ date: git Last Modified
{% endif %}
<span class="middot"></span>
<span>by <span class="author by" id="author">{{ site.name }}</span></span>
<span class="middot"></span>
{% if entry.data.tags %}
<span class="middot"></span>
<span>in
{% for tag in entry.data.tags %}
<span class="tag"><a href="/posts/tagged/{{ tag | slugify }}/">{{ tag }}</a></span>{% if not loop.last %}, {% endif %}