Skip to content

Commit

Permalink
build: update to lume v2.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jrson83 committed Jul 12, 2024
1 parent 581bfcc commit a818a4c
Show file tree
Hide file tree
Showing 34 changed files with 183 additions and 209 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
BUILD_MODE: prod

jobs:
test:
name: Run tests
Expand Down
16 changes: 9 additions & 7 deletions _config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { config } from './_build.ts'

import lume from 'lume/mod.ts'
import date from 'lume/plugins/date.ts'
import feed from 'lume/plugins/feed.ts'
import inline from 'lume/plugins/inline.ts'
import jsx from 'lume/plugins/jsx_preact.ts'
import unified from 'lume/plugins/remark.ts'
import remark from 'lume/plugins/remark.ts'
import sass from 'lume/plugins/sass.ts'
import sitemap from 'lume/plugins/sitemap.ts'
import slugify_urls from 'lume/plugins/slugify_urls.ts'
import terser from 'lume/plugins/terser.ts'

import atomFeed from '#plugins/atom-feed/mod.ts'
import md5CacheBuster from '#plugins/md5-cache-buster/mod.ts'
import rehypePlugins from '#plugins/unified/rehype/mod.ts'
import remarkPlugins from '#plugins/unified/remark/mod.ts'
Expand Down Expand Up @@ -39,16 +39,18 @@ site
'@': '',
},
}))
.use(unified({
remarkPlugins,
rehypePlugins,
}))
.use(remark(
{
remarkPlugins,
rehypePlugins,
},
))
.use(jsx())
.use(sass())
.loadAssets(['.js'])
.use(terser())
.use(inline())
.use(atomFeed())
.use(feed())
.use(sitemap({
query: 'indexable=true',
}))
Expand Down
9 changes: 4 additions & 5 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"importMap": "import_map.json",
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "npm:preact"
"jsxImportSource": "npm:preact",
"types": [
"lume/types.ts"
]
},
"tasks": {
"clean": "rm -rf ./_site",
Expand All @@ -17,10 +20,6 @@
"rules": {
"tags": [
"recommended"
],
"exclude": [
"no-explicit-any",
"no-unused-vars"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion import_map.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"imports": {
"lume/": "https://deno.land/x/lume@v1.19.4/",
"lume/": "https://deno.land/x/lume@v2.2.3/",
"#plugins/": "./plugins/",
"#types": "./src/_includes/types.ts",
"#utils": "./src/_includes/utils/index.ts"
Expand Down
4 changes: 4 additions & 0 deletions plugins/_deprecated/atom-feed/deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @ts-nocheck
// deno-lint-ignore-file -- The plugin is deprecated in favour of: https://lume.land/plugins/sitemap/

export * as XMLFormat from 'npm:[email protected]'
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// @ts-nocheck
// deno-lint-ignore-file -- The plugin is deprecated in favour of: https://lume.land/plugins/sitemap/

import { Page } from 'lume/core/filesystem.ts'
import { buildSort } from 'lume/core/searcher.ts'
import { merge } from 'lume/core/utils.ts'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-nocheck
// deno-lint-ignore-file -- The plugin is deprecated in favour of: https://www.npmjs.com/package/rehype-slug-anchor-sectionize
import type { Element, Root } from 'npm:@types/[email protected]'
import {
findAfter,
Expand All @@ -6,7 +8,7 @@ import {
toString as hastToString,
unified,
visit,
} from '../deps.ts'
} from '../../unified/deps.ts'

export interface RehypeSlugAnchorSectionizeOptions {
/** The heading level depth to sectionize. defaults to `3` */
Expand Down
1 change: 1 addition & 0 deletions plugins/_deprecated/sitemap/mod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
// deno-lint-ignore-file -- The plugin is deprecated in favour of: https://lume.land/plugins/sitemap/

import { Page } from 'lume/core/filesystem.ts'
Expand Down
1 change: 0 additions & 1 deletion plugins/atom-feed/deps.ts

This file was deleted.

21 changes: 9 additions & 12 deletions plugins/md5-cache-buster/mod.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { merge } from 'lume/core/utils.ts'
import { merge } from 'lume/core/utils/object.ts'
import modifyUrls from 'lume/plugins/modify_urls.ts'
import { Md5 } from './deps.ts'

import type { Page, Site } from 'lume/core.ts'
import type { Message } from './deps.ts'

export interface Options {
Expand All @@ -28,26 +27,24 @@ export default function (userOptions?: Partial<Options>) {

const hashedAssets: HashedAssets = []

return (site: Site) => {
return (site: Lume.Site) => {
site.addEventListener('afterRender', () => {
site.process(options.extensions, buildHash)
site.process(options.extensions, (pages) => pages.forEach(buildHash))

site.process(['.html'], replaceUrls)
})

function buildHash(file: Page) {
const hash = new Md5().update(file.content as Message).toString()
function buildHash(page: Lume.Page) {
const hash = new Md5().update(page.content as Message).toString()

hashedAssets.push({
filename: `${file.dest.path}${file.dest.ext}`,
hashFilename: `${file.dest.path}.${hash}${file.dest.ext}`,
ext: file.dest.ext,
filename: `${page.src.path}${page.src.ext}`,
hashFilename: `${page.src.path}.${hash}${page.src.ext}`,
ext: page.src.ext,
hash: hash,
})

file.updateDest({
path: `${file.dest.path}.${hash}`,
})
page.data.url = `${page.src.path}.${hash}${page.src.ext}`
}

function replaceUrls() {
Expand Down
10 changes: 5 additions & 5 deletions plugins/unified/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export { default as rehypeSanitize } from 'npm:[email protected]'
export { default as rehypeStringify } from 'npm:[email protected]'
export { default as remarkGfm } from 'npm:[email protected]'
export { default as remarkParse } from 'npm:[email protected]'
export { default as remarkRehype } from 'npm:remark-rehype@11.0.0'
export * as unified from 'npm:[email protected].3'
export { default as remarkRehype } from 'npm:remark-rehype@11.1.0'
export * as unified from 'npm:[email protected].5'

export { default as readingTime } from 'https://esm.sh/[email protected]?bundle'

Expand All @@ -13,14 +13,14 @@ export { default as rehypeCodeTitles } from 'npm:[email protected]'
export { default as rehypeExternalLinks } from 'npm:[email protected]'
export { default as rehypeMinifyWhitespace } from 'npm:[email protected]'
export { default as rehypePrismDiff } from 'npm:[email protected]'
export { default as rehypePrismPlus } from 'npm:[email protected]'
export { default as rehypePrismPlus } from 'npm:[email protected]'
export { default as rehypeSlugAnchorSectionize } from 'npm:[email protected]'

export { slug } from 'npm:[email protected]'
export { toString } from 'npm:[email protected]'
export { findAfter } from 'npm:[email protected]'
export { CONTINUE, EXIT, SKIP, visit } from 'npm:[email protected]'

export { default as rehypeCopyCode } from '#plugins/unified/rehype/rehypeCopyCode.ts'
export { default as rehypeImgSize } from 'npm:[email protected]'
export type { Test } from 'npm:[email protected]'
export { default as rehypeCopyCode } from './rehype/rehypeCopyCode.ts'
export { default as rehypeSlugAnchorSectionize } from './rehype/slug.ts'
3 changes: 2 additions & 1 deletion plugins/unified/rehype/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import {
rehypePrismDiff,
rehypePrismPlus,
rehypeSlugAnchorSectionize,
unified,
} from '../deps.ts'

const __dirname = dirname(fromFileUrl(import.meta.url))

export default [
export default <unified.PluggableList> [
[rehypeImgSize, {
dir: new URL(`${__dirname}/../../../src/assets`, import.meta.url).pathname,
}],
Expand Down
4 changes: 2 additions & 2 deletions plugins/unified/remark/mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readingTime } from '../deps.ts'
import { readingTime, unified } from '#plugins/unified/deps.ts'

export default [
export default <unified.PluggableList> [
[readingTime, { name: 'readingTime' }],
]
4 changes: 1 addition & 3 deletions src/404.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { PageData, PageHelpers } from '#types'

export const indexable = false
export const title = '404: Page Not Found'
export const layout = 'layouts/root.tsx'
export const url = '/404/'

export default (_data: PageData, { urlFilter }: PageHelpers) => {
export default (_data: Lume.Data, { urlFilter }: Lume.Helpers) => {
return (
<>
<h1>{title}</h1>
Expand Down
4 changes: 1 addition & 3 deletions src/_components/blog/header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { PageData } from '#types'

export default (
{ comp, title, date, icons: { unicons }, readingTime, tags }: PageData,
{ comp, title, date, icons: { unicons }, readingTime, tags }: Lume.PageProps,
) => {
return (
<header>
Expand Down
5 changes: 2 additions & 3 deletions src/_components/blog/pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { PageData, PageHelpers } from '#types'
import { getPaginationPages } from '#utils'

export default (
{ comp, icons: { unicons }, pagination }: PageData,
{ urlFilter }: PageHelpers,
{ comp, icons: { unicons }, pagination }: Lume.PageProps,
{ urlFilter }: Lume.Helpers,
) => {
return (
<nav id='pagination'>
Expand Down
6 changes: 2 additions & 4 deletions src/_components/blog/post.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { PageData, PageHelpers } from '#types'

export default (
{
comp,
Expand All @@ -11,8 +9,8 @@ export default (
excerpt,
url,
index,
}: PageData,
{ urlFilter }: PageHelpers,
}: Lume.PageProps,
{ urlFilter }: Lume.Helpers,
) => {
return (
<article
Expand Down
2 changes: 1 addition & 1 deletion src/_components/blog/search.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default ({ query }: { query: string }) => {
export default ({ query }: Lume.PageProps) => {
return (
<>
<div id='search-inner' className='search'>
Expand Down
22 changes: 10 additions & 12 deletions src/_components/blog/showcase.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import type { Page, PageData, PageHelpers } from '#types'

import { isEmptyArray, truncateString } from '#utils'

export default (
{ comp, icons: { unicons }, search, url }: PageData,
{ urlFilter }: PageHelpers,
{ comp, icons: { unicons }, search, url }: Lume.PageProps,
{ urlFilter }: Lume.Helpers,
) => {
const previousPost = search?.previousPage(
url?.toString(),
const previousPost = search.previousPage(
url.toString(),
'type=post',
) as Page
)

const nextPost = search?.nextPage(
url?.toString(),
const nextPost = search.nextPage(
url.toString(),
'type=post',
) as Page
)

return (
<nav
Expand Down Expand Up @@ -44,7 +42,7 @@ export default (
<small itemProp='name'>Previous</small>
<span>
{truncateString(
previousPost.data.title as string,
previousPost.title!,
30,
'...',
true,
Expand All @@ -67,7 +65,7 @@ export default (
<small itemProp='name'>Next</small>
<span>
{truncateString(
nextPost.data.title as string,
nextPost.title!,
30,
'...',
true,
Expand Down
4 changes: 1 addition & 3 deletions src/_components/blog/tag.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { PageData, PageHelpers } from '#types'

export default ({ tags }: PageData, { urlFilter }: PageHelpers) => {
export default ({ tags }: Lume.Data, { urlFilter }: Lume.Helpers) => {
return (
<>
{tags?.map((tag: string, index: number) => {
Expand Down
4 changes: 1 addition & 3 deletions src/_components/blog/time.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { PageData, PageHelpers } from '#types'

export default ({ date }: PageData, filters: PageHelpers) => {
export default ({ date }: Lume.Data, filters: Lume.Helpers) => {
return (
<time dateTime={filters.date(date, 'DATE')} itemProp='datePublished'>
{filters.date(date, 'HUMAN_DATE')}
Expand Down
16 changes: 7 additions & 9 deletions src/_components/blog/tocSeries.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import type { Page, PageData, PageHelpers } from '#types'

import { capitalize, isEmptyArray } from '#utils'

export default (
{ comp, icons: { unicons }, search, series, url }: PageData,
{ urlFilter }: PageHelpers,
{ comp, icons: { unicons }, search, series, url }: Lume.PageProps,
{ urlFilter }: Lume.Helpers,
) => {
const parts: any[] = []
const parts: { title: string; url: string; chapter?: string }[] = []
const activeUrl = url

if (typeof series !== 'undefined') {
for (
const post of search.pages(
const data of search.pages(
`series.ident=${series.ident}`,
'date=asc',
) as Page[]
)
) {
parts.push({
title: series.title,
chapter: post.data.title,
url: urlFilter!(post.data.url),
url: urlFilter!(data.url),
chapter: data.title,
})
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/_components/layout/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { PageData, PageHelpers } from '#types'

export default ({ comp, site }: PageData, { urlFilter }: PageHelpers) => {
export default (
{ comp, site }: Lume.PageProps,
{ urlFilter }: Lume.Helpers,
) => {
return (
<footer className='container'>
<p>
Expand Down
Loading

0 comments on commit a818a4c

Please sign in to comment.