Skip to content

Commit

Permalink
convert to lume
Browse files Browse the repository at this point in the history
  • Loading branch information
RickCogley committed Nov 12, 2024
1 parent 35d7d16 commit f61285e
Show file tree
Hide file tree
Showing 83 changed files with 2,266 additions and 171 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish on Deno Deploy

on:
push:
# Run on main branch pushes
branches: [master]
# Allow to manually trigger the workflow
workflow_dispatch:
schedule:
# Rebuild every day at 8:04 PM UTC
- cron: '4 20 * * *'

jobs:
build:
# What OS to use
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

# What steps to run
steps:
- name: Clone repository
# Git clone the repository
uses: actions/checkout@v4

- name: Setup Deno environment
# Downloads deno and caches it
uses: denoland/setup-deno@v2
with:
# Latest Deno 2.x version
deno-version: v2.x

- name: Build site
# Run the build script from deno.json
run: deno task build

- name: Deploy to Deno Deploy
# Push the built site to Deno Deploy
uses: denoland/deployctl@v1
with:
# Deno Deploy project name
project: rick-cogley-jp
# Where are the deno components located
import-map: "./deno.json"
# Which file acts as the web server
entrypoint: serve.ts
Empty file added .zed/settings.json
Empty file.
180 changes: 180 additions & 0 deletions _cms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
import lumeCMS from "lume/cms/mod.ts";
import GitHub from "lume/cms/storage/github.ts";
import { Octokit } from "npm:octokit";

const username = Deno.env.get("USERNAME1")!;
const password = Deno.env.get("PASSWORD1")!;

const cms = lumeCMS({
site: {
name: "Julie Cogley Portfolio CMS",
description: "Edit the content of the Julie Cogley Portfolio site.",
url: "https://julie.cogley.jp",
body: `
<p>This is the CMS for a Japanese-language portfolio site, with a top index page, an about page, showcase pages to provide narrative about projects, and as-is copies of specific sites to act as a design archive.</p>
`,
},
auth: {
method: "basic",
users: {
// foo: "bar",
[username]: password,
},
},
});

// Register GitHub storage
cms.storage(
"gh",
new GitHub({
client: new Octokit({ auth: Deno.env.get("GITHUB_TOKEN") }),
owner: "juliecogley",
repo: "julie_portfolio",
branch: "main",
path: "src",
}),
);

// Configure an upload folder
cms.upload("assets", "gh:assets");

// Showcase pages collection
cms.collection(
"showcase",
"gh:showcase/*.vto",
[
{
name: "indextitle",
type: "text",
label: "Title for Top Index",
description: "Visible when hovering mouse over the top index image link",
attributes: {
required: true,
},
},
{
name: "indeximage",
type: "file",
label: "Image for Top Index",
description: "Image to display on the top page showcase grid.",
attributes: {
accept: "image/*",
required: true,
},
},
{
name: "metas",
type: "object",
fields: [
{
name: "title",
type: "text",
label: "Title of the Page",
description: "Visible in browser tab and page source head section",
attributes: {
required: true,
},
},
{
name: "description",
type: "textarea",
label: "Description for the Page",
description: "Visible in search engine results",
attributes: {
required: true,
},
},
{
name: "image",
type: "file",
description: "Image to link in head metadata.",
attributes: {
accept: "image/*",
required: true,
},
},
],
},
{
name: "category",
type: "select",
label: "Category",
description: "Category to categorize the page on the top index",
init(field) {
field.options = ["clientwork", "work", "classwork", "hobby"];
},
},
"draft: checkbox",
{
name: "order",
type: "number",
label: "Order",
description:
"Order in which the page will appear in the top menu. View all showcase pages at /showcase/ to see how the order number is currently set.",
attributes: {
required: true,
},
},
"content: markdown",
],
);

cms.document({
name: "Top Page",
description: "Edit the content of the home page",
store: "gh:index.vto",
fields: [
"title: text",
"description: text",
{
name: "priority",
type: "number",
label: "Priority for sitemap",
description:
"1 is highest priority, 0 is lowest priority, and you can set decimal numbers in between like 0.9.",
attributes: {
required: false,
min: 0,
max: 1,
step: 0.1,
},
},
"content: markdown",
],
});

cms.document({
name: "About Page",
description: "Edit the content of the about page",
store: "gh:about.vto",
fields: [
"title: text",
"description: text",
{
name: "priority",
type: "number",
label: "Priority for sitemap",
description:
"1 is highest priority, 0 is lowest priority, and you can set decimal numbers in between like 0.9.",
attributes: {
required: false,
min: 0,
max: 1,
step: 0.1,
},
},
"content: markdown",
],
});

cms.document({
name: "ld-person",
description:
"Edit the content of the ld-person script for the person, which will appear in the head of the about page",
store: "gh:_includes/templates/ld-person.vto",
fields: [
"content: markdown",
],
});

export default cms;
89 changes: 89 additions & 0 deletions _config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import lume from "lume/mod.ts";
import attributes from "lume/plugins/attributes.ts";
import base_path from "lume/plugins/base_path.ts";
import date from "lume/plugins/date.ts";
import { enUS } from "npm:date-fns/locale/en-US";
import { ja } from "npm:date-fns/locale/ja";
// import favicon from "lume/plugins/favicon.ts";
import feed from "lume/plugins/feed.ts";
import filter_pages from "lume/plugins/filter_pages.ts";
import inline from "lume/plugins/inline.ts";
import lightningcss from "lume/plugins/lightningcss.ts";
import metas from "lume/plugins/metas.ts";
// import minify_html from "lume/plugins/minify_html.ts";
import nav from "lume/plugins/nav.ts";
import pagefind from "lume/plugins/pagefind.ts";
import robots from "lume/plugins/robots.ts";
import sitemap from "lume/plugins/sitemap.ts";
import source_maps from "lume/plugins/source_maps.ts";
import sri from "lume/plugins/sri.ts";
import terser from "lume/plugins/terser.ts";
import phosphor from "https://deno.land/x/[email protected]/phosphor.ts";
import picture from "lume/plugins/picture.ts";
import transformImages from "lume/plugins/transform_images.ts";
import brotli from "lume/plugins/brotli.ts";

const site = lume(
{
src: "./src",
location: new URL("https://rick.cogley.jp"),
},
);

site.use(attributes());
site.use(base_path());
site.use(date({ locales: { enUS, ja } }));
// site.use(favicon());
site.use(feed());
site.use(filter_pages());
site.use(inline());
site.use(lightningcss());
site.use(metas());
// site.use(minify_html());
site.use(nav());
site.use(pagefind());
site.use(robots());
site.use(sitemap({
// query: "external_link=undefined",
lastmod: "lastmod",
priority: "priority",
filename: "sitemap.xml",
sort: "lastmod=desc",
}));
site.use(source_maps());
site.use(sri());
site.use(terser());
site.use(phosphor());
site.use(picture(/* Options */));
site.use(transformImages({
cache: true, // Toggle cache
matches: /\.(jpg|jpeg|png|webp)$/i, // This regex matches only image files
}));
site.use(brotli());

//site.copy("assets", "assets");
site.copy("static/portfolio", "portfolio");
//site.copy([".gif",".pdf",".docx",".pptx",".xlsx",".zip",".svg"]);
site.copyRemainingFiles();

// Create zip and tree scripts
site.script(
"zipsite",
"zip -r _site/rick_cogley_jp_site.zip _site",
);
site.script(
"maketree",
"cd _site && tree -H . -L 5 --charset utf-8 -C -h -o rick_cogley_jp_tree.html",
);
// site.script(
// "getjpholidays",
// "cd src/_data && curl https://holidays-jp.github.io/api/v1/date.json -o jp_holidays.json",
// );

// Execute scripts before build
// site.addEventListener("beforeBuild", "getjpholidays");
// Execute scripts after build
site.addEventListener("afterBuild", "zipsite");
site.addEventListener("afterBuild", "maketree");

export default site;
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading

1 comment on commit f61285e

@deno-deploy
Copy link
Contributor

@deno-deploy deno-deploy bot commented on f61285e Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to deploy:

Module not found "file:///src/index.ts".

Please sign in to comment.