From 202e079c67692455d1e676417940f448d2a7bc6c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=97=8D+85CD?= <50108258+kwaa@users.noreply.github.com>
Date: Fri, 19 Jan 2024 23:52:32 +0800
Subject: [PATCH] chore: format code
---
examples/lume-blog/_config.test.ts | 2 +-
lume/plugins/_experimental/object_article.ts | 75 ++++++++++----------
lume/plugins/hatsu.ts | 41 ++++++-----
3 files changed, 61 insertions(+), 57 deletions(-)
diff --git a/examples/lume-blog/_config.test.ts b/examples/lume-blog/_config.test.ts
index db78ea9..1032b76 100644
--- a/examples/lume-blog/_config.test.ts
+++ b/examples/lume-blog/_config.test.ts
@@ -7,7 +7,7 @@ Deno.test('build examples/lume-blog', async () => {
// await build(site)
// await assertSiteSnapshot(t, site)
await site.build()
- .catch(err => console.error(Deno.inspect(err, { colors: true })))
+ .catch((err) => console.error(Deno.inspect(err, { colors: true })))
assertEquals(site.options.location, new URL('https://aoba-test.netlify.app'))
})
diff --git a/lume/plugins/_experimental/object_article.ts b/lume/plugins/_experimental/object_article.ts
index 4600da2..d3fb6ee 100644
--- a/lume/plugins/_experimental/object_article.ts
+++ b/lume/plugins/_experimental/object_article.ts
@@ -3,42 +3,43 @@ import { Page } from 'lume/core/file.ts'
export default () => (site: Lume.Site) => {
// site.process(['.md', '.mdx'], (page, pages) => {
- site.process(['.md'], (pages) => pages.forEach((page) => {
- const match = page.outputPath?.match(/^\/posts\/([^\/?#]+)\/index.html$/)
- if (match?.[1]) {
- // Create Article Object
- pages.push(Page.create({
- url: `/notice/${match[1]}`,
- content: JSON.stringify(
- {
- '@context': ['https://www.w3.org/ns/activitystreams'],
- attributedTo: new URL('/actor', site.options.location).href,
- // cc: [],
- // TODO: test
- content: page.data.children,
- id: new URL(`/notice/${match[1]}`, site.options.location).href,
- published: (page.data.date ?? new Date()).toISOString(),
- source: {
- content: page.data.content,
- mediaType: 'text/markdown',
+ site.process(['.md'], (pages) =>
+ pages.forEach((page) => {
+ const match = page.outputPath?.match(/^\/posts\/([^\/?#]+)\/index.html$/)
+ if (match?.[1]) {
+ // Create Article Object
+ pages.push(Page.create({
+ url: `/notice/${match[1]}`,
+ content: JSON.stringify(
+ {
+ '@context': ['https://www.w3.org/ns/activitystreams'],
+ attributedTo: new URL('/actor', site.options.location).href,
+ // cc: [],
+ // TODO: test
+ content: page.data.children,
+ id: new URL(`/notice/${match[1]}`, site.options.location).href,
+ published: (page.data.date ?? new Date()).toISOString(),
+ source: {
+ content: page.data.content,
+ mediaType: 'text/markdown',
+ },
+ tag: [],
+ to: 'https://www.w3.org/ns/activitystreams#Public',
+ type: 'Article',
},
- tag: [],
- to: 'https://www.w3.org/ns/activitystreams#Public',
- type: 'Article',
- },
- null,
- 2,
- ),
- }))
- // Set
- const link = page.document!.createElement('link')
- link?.setAttribute('rel', 'alternate')
- link?.setAttribute('type', 'application/activity+json')
- link?.setAttribute(
- 'href',
- new URL(`/notice/${match[1]}`, site.options.location).href,
- )
- page.document!.head.appendChild(link)
- }
- }))
+ null,
+ 2,
+ ),
+ }))
+ // Set
+ const link = page.document!.createElement('link')
+ link?.setAttribute('rel', 'alternate')
+ link?.setAttribute('type', 'application/activity+json')
+ link?.setAttribute(
+ 'href',
+ new URL(`/notice/${match[1]}`, site.options.location).href,
+ )
+ page.document!.head.appendChild(link)
+ }
+ }))
}
diff --git a/lume/plugins/hatsu.ts b/lume/plugins/hatsu.ts
index 08a76ce..2d52de3 100644
--- a/lume/plugins/hatsu.ts
+++ b/lume/plugins/hatsu.ts
@@ -50,25 +50,28 @@ export const hatsuPlugin = (options: Options): Plugin => (site: Lume.Site) => {
})
// set for matched page
- site.process(['.html'], (pages) => pages.forEach((page) => {
- // console.log(page.outputPath, page.data.url)
- if (
- page.document &&
- (!options.match || options.match?.some((matcher) => (page.data.url as string).match(matcher)))
- ) {
- const link = page.document.createElement('link')
- link?.setAttribute('rel', 'alternate')
- link?.setAttribute('type', 'application/activity+json')
- link?.setAttribute(
- 'href',
- new URL(
- `/o/${new URL(page.data.url, site.options.location).href}`,
- options.instance,
- ).href,
- )
- page.document.head.appendChild(link)
- }
- }))
+ site.process(['.html'], (pages) =>
+ pages.forEach((page) => {
+ // console.log(page.outputPath, page.data.url)
+ if (
+ page.document &&
+ (!options.match || options.match?.some((matcher) =>
+ (page.data.url as string).match(matcher)
+ ))
+ ) {
+ const link = page.document.createElement('link')
+ link?.setAttribute('rel', 'alternate')
+ link?.setAttribute('type', 'application/activity+json')
+ link?.setAttribute(
+ 'href',
+ new URL(
+ `/o/${new URL(page.data.url, site.options.location).href}`,
+ options.instance,
+ ).href,
+ )
+ page.document.head.appendChild(link)
+ }
+ }))
}
export default hatsuPlugin