💥 giving lume / deno a try
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
James Walker 2024-05-23 15:37:43 -04:00
parent 19f785af09
commit df332d5b2b
Signed by: walkah
SSH Key Fingerprint: SHA256:f7Gn4jO4BFHZxWfKTTzEAfWz+cLW51IyGFl9MjDyZGI
21 changed files with 1508 additions and 6028 deletions

View File

@ -4,14 +4,9 @@ name: default
steps:
- name: build
image: node:lts-alpine
environment:
GHOST_API_URL: https://admin.walkah.blog
GHOST_CONTENT_API_KEY:
from_secret: GHOST_CONTENT_API_KEY
image: denoland/deno
commands:
- npm install
- npm run build
- deno task build
- name: publish
image: walkah.dev/walkah/drone-ipfs-cluster
settings:

View File

@ -1,70 +0,0 @@
require("dotenv").config();
const GhostContentAPI = require("@tryghost/content-api");
const pluginNavigation = require("@11ty/eleventy-navigation");
const pluginRss = require("@11ty/eleventy-plugin-rss");
const localImages = require('eleventy-plugin-local-images');
const path = require("path");
const api = new GhostContentAPI({
url: process.env.GHOST_API_URL,
key: process.env.GHOST_CONTENT_API_KEY,
version: "v3.0"
});
const stripDomain = url => {
return url.replace(process.env.GHOST_API_URL, "");
};
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(pluginNavigation);
eleventyConfig.addPlugin(pluginRss);
eleventyConfig.addPassthroughCopy("css");
eleventyConfig.addPassthroughCopy("images");
eleventyConfig.addPlugin(localImages, {
distPath: '_site',
assetPath: '/assets/images',
selector: 'img',
verbose: false
});
eleventyConfig.addFilter("dateString", (dateObj) => {
return new Date(dateObj).toISOString().split("T")[0];
});
eleventyConfig.addFilter("relativePath", (pathToFilter, page) => {
if (!pathToFilter.startsWith("/")) {
return pathToFilter;
}
return path.relative(page.url, pathToFilter);
})
eleventyConfig.addCollection("posts", async function (collection) {
collection = await api.posts
.browse({
include: "tags,authors",
limit: "all",
})
.catch((err) => {
console.error(err);
});
collection.forEach((post) => {
post.url = stripDomain(post.url);
post.primary_author.url = stripDomain(post.primary_author.url);
// Convert publish date into a Date object
post.date = new Date(post.published_at);
post.published_at = new Date(post.published_at);
post.updated_at = new Date(post.updated_at);
});
// Bring featured post to the top of the list
collection.sort((post, nextPost) => nextPost.featured - post.featured);
return collection;
});
}

5
.gitignore vendored
View File

@ -1,4 +1,5 @@
_site
_cache
.DS_Store
/node_modules
/_site
/.env
/.direnv

39
_config.ts Normal file
View File

@ -0,0 +1,39 @@
import lume from "lume/mod.ts";
import date from "lume/plugins/date.ts";
import feed from "lume/plugins/feed.ts";
import metas from "lume/plugins/metas.ts";
import nunjucks from "lume/plugins/nunjucks.ts";
import postcss from "lume/plugins/postcss.ts";
import relativeUrls from "lume/plugins/relative_urls.ts";
import tailwindcss from "lume/plugins/tailwindcss.ts";
import terser from "lume/plugins/terser.ts";
import tailwindConfig from "./tailwind.config.js";
const site = lume();
site.copy("images");
site.use(date());
site.use(feed({
output: ["/feed.rss", "/feed.json"],
info: {
title: "=site.title",
description: "=site.description",
},
items: {
title: "=title",
description: "=excerpt",
},
query: "type=post"
}));
site.use(metas());
site.use(nunjucks());
site.use(tailwindcss({
options: tailwindConfig,
}));
site.use(postcss());
site.use(relativeUrls());
site.use(terser());
export default site;

6
_data.yml Normal file
View File

@ -0,0 +1,6 @@
metas:
site: walkah.blog
description: James Walker has a blog
title: "=title"
image: "=image"
lang: en

View File

@ -1,19 +0,0 @@
{
"title": "walkah",
"url": "https://walkah.blog/",
"description": "It's a new blog, just like the old blog.",
"feed": {
"filename": "feed.xml",
"path": "/feed.xml",
"id": "https://walkah.blog/feed.xml"
},
"jsonfeed": {
"path": "/feed.json",
"url": "https://walkah.blog/feed.json"
},
"author": {
"name": "James Walker",
"email": "walkah@walkah.net",
"url": "https://walkah.net/"
}
}

View File

@ -1,21 +1,21 @@
<!doctype html>
<html lang="en">
<html lang="{{ it.lang }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title or metadata.title }}</title>
<meta name="description" content="{{ description or metadata.description }}">
<link rel="stylesheet" href="{{ '/css/style.css' | relativePath(page) }}">
<link rel="alternate" href="{{ metadata.feed.path | relativePath(page) }}" type="application/atom+xml" title="{{ metadata.title }}">
<link rel="alternate" href="{{ metadata.jsonfeed.path | relativePath(page) }}" type="application/json" title="{{ metadata.title }}">
<title>{{ title or metas.site }}</title>
<meta name="description" content="{{ description or metas.description }}">
<link rel="stylesheet" href="/css/style.css">
<link rel="alternate" href="https://walkah.blog/feed.rss" type="application/rss+xml">
<link rel="alternate" href="https://walkah.blog/feed.json" type="application/json">
</head>
<body class="bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100">
<div class="container max-w-2xl mb-24 mt-8 mx-auto">
<div class="px-5 md:px-8">
<header class="flex flex-row not-prose my-8">
<div rel="author" class="p-author h-card basis-1/2">
<a href="{{ "/" | relativePath(page) }}">
<img class="u-photo w-8 inline-block" src="{{ "/images/walkah-avatar.png" | relativePath(page) }}"> walkah
<a href="/">
<img class="u-photo w-8 inline-block" src="/images/walkah-avatar.png"> walkah
</a>
</div>
</header>

View File

@ -1,9 +1,5 @@
{% extends 'layouts/default.njk' %}
{% set title = post.title %}
{% set codeinjection_head = post.codeinjection_head %}
{% set codeinjection_foot = post.codeinjection_foot %}
{% block content %}
<article class="h-entry prose lg:prose-lg dark:prose-invert" role="article">
<header>
@ -23,14 +19,11 @@
{{ content | safe }}
</section>
<footer class="flex flex-row not-prose">
<div rel="author" class="p-author h-card basis-1/2">
<time class="dt-published" datetime="{{ post.published_at }}" pubdate>
<a class="u-url text-gray-500 text-sm" href="{{ post.url | relativePath(page) }}">{{ post.date | dateString }}</a>
<div class="basis-1/2">
<time class="dt-published" datetime="{{ date | date('DATETIME') }}" pubdate>
<a class="u-url text-gray-500 text-sm" href="{{ post.url }}">{{ date | date }}</a>
</time>
</div>
<div class="text-right basis-1/2">
</div>
</footer>
</article>
{% endblock %}

15
deno.json Normal file
View File

@ -0,0 +1,15 @@
{
"imports": {
"lume/": "https://deno.land/x/lume@v2.2.0/"
},
"tasks": {
"lume": "echo \"import 'lume/cli.ts'\" | deno run -A -",
"build": "deno task lume",
"serve": "LUME_DRAFTS=true deno task lume -s"
},
"compilerOptions": {
"types": [
"lume/types.ts"
]
}
}

1411
deno.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +0,0 @@
version: "3"
services:
ghost:
image: ghost:5-alpine
ports:
- 2368:2368
env_file: .env
environment:
# see https://ghost.org/docs/config/#configuration-options
database__client: mysql
database__connection__host: db
database__connection__user: ${DB_USER}
database__connection__password: ${DB_PASSWORD}
database__connection__database: ${DB_NAME}
url: ${GHOST_URL}
labels:
- traefik.http.routers.ghost.rule=Host(`${GHOST_DOMAIN}`)
- traefik.http.routers.ghost.tls=true
- traefik.http.routers.ghost.tls.certresolver=myresolver
restart: unless-stopped
volumes:
- ghost:/var/lib/ghost/content
db:
image: mariadb:11
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
volumes:
- mariadb:/var/lib/mysql
volumes:
ghost:
mariadb:

View File

@ -1,39 +0,0 @@
---
permalink: "{{ metadata.feed.path | url }}"
eleventyExcludeFromCollections: true
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
<title>{{ metadata.title }}</title>
{% set absoluteUrl %}{{ metadata.feed.path | url | absoluteUrl(metadata.url) }}{% endset %}
<link href="{{ absoluteUrl }}" rel="self" type="application/atom+xml" />
<link href="{{ metadata.url }}" type="text/html" />
<updated>{{ collections.posts | rssLastUpdatedDate }}</updated>
<id>{{ metadata.feed.id }}</id>
<author>
<name>{{ metadata.author.name }}</name>
<email>{{ metadata.author.email }}</email>
</author>
{%- for post in collections.posts | reverse %}
{% set absolutePostUrl %}{{ post.url | url | absoluteUrl(metadata.url) }}{% endset %}
<entry>
<title>{{ post.title }}</title>
<link href="{{ absolutePostUrl }}" rel="alternate" type="text/html" title="{{ post.title }}" />
<pubdate>{{ post.published_at | rssDate }}</pubdate>
<updated>{{ post.updated_at | rssDate }}</updated>
<id>{{ absolutePostUrl }}</id>
<summary type="html">{{ post.excerpt | htmlToAbsoluteUrls(absolutePostUrl) }}</summary>
<content type="html">{{ post.html | htmlToAbsoluteUrls(absolutePostUrl) }}</content>
<author>
<name>{{ metadata.author.name }}</name>
</author>
{% if post.primary_tag %}
<category term="{{ post.primary_tag.name }}" />
{% endif %}
{% if post.feature_image %}
<media:thumbnail url="{{ post.feature_image }}" />
<media:content medium="image" url="{{ post.feature_image }}"/>
{% endif %}
</entry>
{%- endfor %}
</feed>

View File

@ -1,34 +0,0 @@
---
permalink: "{{ metadata.jsonfeed.path | url }}"
eleventyExcludeFromCollections: true
---
{
"version": "https://jsonfeed.org/version/1",
"title": "{{ metadata.title }}",
"home_page_url": "{{ metadata.url }}",
"feed_url": "{{ metadata.jsonfeed.url }}",
"description": "{{ metadata.description }}",
"authors": [{
"name": "{{ metadata.author.name }}",
"url": "{{ metadata.author.url }}"
}],
"language": "en",
"items": [
{%- for post in collections.posts | reverse %}
{%- set absolutePostUrl %}{{ post.url | url | absoluteUrl(metadata.url) }}{% endset -%}
{
"id": "{{ absolutePostUrl }}",
"url": "{{ absolutePostUrl }}",
"title": "{{ post.title }}",
"summary": "{{ post.excerpt }}",
"content_html": {% if post.html %}{{ post.html | dump | safe }}{% else %}""{% endif %},
{% if post.feature_image %}"image": "{{ post.feature_image }}",{% endif %}
"date_published": "{{ post.published_at | rssDate }}",
"date_modified": "{{ post.updated_at | rssDate }}"
}
{%- if not loop.last -%}
,
{%- endif -%}
{%- endfor %}
]
}

View File

@ -36,16 +36,16 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1712588820,
"narHash": "sha256-y31s5idk3jMJMAVE4Ud9AdI7HT3CgTAeMTJ0StqKN7Y=",
"lastModified": 1716312448,
"narHash": "sha256-PH3w5av8d+TdwCkiWN4UPBTxrD9MpxIQPDVWctlomVo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d272ca50d1f7424fbfcd1e6f1c9e01d92f6da167",
"rev": "e381a1288138aceda0ac63db32c7be545b446921",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-23.11",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}

View File

@ -2,7 +2,7 @@
description = "walkah's blog";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
@ -18,7 +18,7 @@
{
devShells.default = pkgs.mkShell {
name = "blog";
buildInputs = with pkgs; [ nodejs ];
buildInputs = with pkgs; [ deno ];
};
}
);

View File

@ -6,20 +6,20 @@ pagination:
---
{% extends 'layouts/default.njk' %}
{% block content %}
{% set postslist = collections.posts %}
{% set postslist = search.pages("type=post") %}
<section class="h-feed">
{% for post in postslist %}
<article class="h-entry">
<h2 class="p-name">
<a href="{{ post.url | relativePath(page) }}">{{ post.title }}</a>
<a href="{{ post.url }}">{{ post.title }}</a>
</h2>
<div class="e-content">
{{ post.excerpt | safe }}
</div>
<time class="dt-published" datetime={{ post.published_at }} pubdate>
<a class="u-url text-gray-500 text-sm" href={{ post.url | relativePath(page) }}>{{ post.date | dateString }}</a>
<time class="dt-published" datetime={{ post.date | date }} pubdate>
<a class="u-url text-gray-500 text-sm" href={{ post.url }}>{{ post.date | date }}</a>
</time>
</article>
{% endfor %}
</section>
</section>
{% endblock %}

5748
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +0,0 @@
{
"name": "walkah.blog",
"version": "1.0.0",
"description": "The new blog. Just like the old blog.",
"scripts": {
"build": "run-s clean prod css:prod",
"clean": "rimraf ./_site",
"css:prod": "tailwindcss -i ./css/style.css -o ./_site/css/style.css --minify",
"css:dev": "tailwindcss -i ./css/style.css -o ./_site/css/style.css --watch",
"dev": "eleventy --serve --watch --port=8000",
"prod": "eleventy",
"start": "run-p clean css:dev dev"
},
"author": {
"name": "James Walker",
"email": "walkah@walkah.net",
"url": "https://walkah.net/"
},
"license": "MIT",
"devDependencies": {
"@11ty/eleventy": "^2.0.0",
"@11ty/eleventy-navigation": "^0.3.3",
"@11ty/eleventy-plugin-rss": "^1.0.9",
"@tailwindcss/typography": "^0.5.2",
"@tryghost/content-api": "^1.9.4",
"dotenv": "^16.0.1",
"eleventy-plugin-local-images": "^0.4.1",
"npm-run-all": "^4.1.5",
"rimraf": "^5.0.5",
"tailwindcss": "^3.0.24"
}
}

5
posts/_data.yml Normal file
View File

@ -0,0 +1,5 @@
layout: layouts/post.njk
type: post
metas:
title: "=title"

View File

@ -1,11 +0,0 @@
---
pagination:
data: collections.posts
size: 1
alias: post
addAllPagesToCollections: true
layout: 'layouts/post.njk'
permalink: '{{ post.url }}'
---
{{ post.html | safe if post.html else "Post content not found" }}

View File

@ -1,11 +1,11 @@
module.exports = {
import typography from "npm:@tailwindcss/typography";
export default {
mode: "jit",
darkMode: "media",
content: ["./**/*.{html,md,njk}"],
theme: {
extend: {},
},
plugins: [
require('@tailwindcss/typography'),
],
}
plugins: [typography],
};