-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ed6c5f
commit 150611c
Showing
4 changed files
with
30 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,9 @@ import resolveUrls from "lume/plugins/resolve_urls.ts"; | |
import metas from "lume/plugins/metas.ts"; | ||
import pagefind, { Options as PagefindOptions } from "lume/plugins/pagefind.ts"; | ||
import sitemap from "lume/plugins/sitemap.ts"; | ||
import feed from "lume/plugins/feed.ts"; | ||
import feed, { Options as FeedOptions } from "lume/plugins/feed.ts"; | ||
import readingInfo from "lume/plugins/reading_info.ts"; | ||
import { merge } from "lume/core/utils/object.ts"; | ||
import toc from "https://deno.land/x/[email protected]/toc.ts"; | ||
import image from "https://deno.land/x/[email protected]/image.ts"; | ||
import footnotes from "https://deno.land/x/[email protected]/footnotes.ts"; | ||
|
@@ -20,10 +21,27 @@ export interface Options { | |
prism?: Partial<PrismOptions>; | ||
date?: Partial<DateOptions>; | ||
pagefind?: Partial<PagefindOptions>; | ||
feed?: Partial<FeedOptions>; | ||
} | ||
|
||
export const defaults: Options = { | ||
feed: { | ||
output: ["/feed.xml", "/feed.json"], | ||
query: "type=post", | ||
info: { | ||
title: "=metas.site", | ||
description: "=metas.description", | ||
}, | ||
items: { | ||
title: "=title", | ||
}, | ||
}, | ||
}; | ||
|
||
/** Configure the site */ | ||
export default function (options: Options = {}) { | ||
export default function (userOptions?: Options) { | ||
const options = merge(defaults, userOptions); | ||
|
||
return (site: Lume.Site) => { | ||
site.use(postcss()) | ||
.use(basePath()) | ||
|
@@ -39,20 +57,11 @@ export default function (options: Options = {}) { | |
.use(terser()) | ||
.use(pagefind(options.pagefind)) | ||
.use(sitemap()) | ||
.use(feed({ | ||
output: ["/feed.xml", "/feed.json"], | ||
query: "type=post", | ||
info: { | ||
title: "=metas.site", | ||
description: "=metas.description", | ||
}, | ||
items: { | ||
title: "=title", | ||
}, | ||
})) | ||
.use(feed(options.feed)) | ||
.copy("fonts") | ||
.copy("js") | ||
.copy("favicon.png") | ||
.mergeKey("extra_head", "stringArray") | ||
.preprocess([".md"], (pages) => { | ||
for (const page of pages) { | ||
page.data.excerpt ??= (page.data.content as string).split( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters