Skip to content

Commit

Permalink
refactor: sort plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Jul 7, 2024
1 parent 2d91850 commit 9414923
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 78 deletions.
3 changes: 2 additions & 1 deletion plugins/mdx.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import mdx from 'lume/plugins/mdx.ts'
import { rehypePlugins, remarkPlugins } from './shared/unified.ts'
import { remarkPlugins } from './unified/remark.ts'
import { rehypePlugins } from './unified/rehype.ts'

export default () => (site: Lume.Site) =>
site
Expand Down
3 changes: 2 additions & 1 deletion plugins/remark.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import remark from 'lume/plugins/remark.ts'
import { rehypePlugins, remarkPlugins } from './shared/unified.ts'
import { remarkPlugins } from './unified/remark.ts'
import { rehypePlugins } from './unified/rehype.ts'

export default () => (site: Lume.Site) =>
site
Expand Down
51 changes: 14 additions & 37 deletions plugins/shared.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,29 @@
import html from './helpers/html.ts'
import slug from './helpers/slug.ts'
import htmlHelper from './helpers/html.ts'
import slugHelper from './helpers/slug.ts'
import data from './lts/data.ts'
import jsx from './lts/jsx.ts'
import theme from './lts/theme.ts'
import readInfo from './patched/reading_info.ts'
// import { getGitDate } from 'lume/core/utils/date.ts'
// import filterPages from 'lume/plugins/filter_pages.ts'
import metas from 'lume/plugins/metas.ts'
import fff from 'lume/plugins/fff.ts'
// import date from 'lume/plugins/date.ts'
import sitemap from 'lume/plugins/sitemap.ts'
import minifyHTML from 'lume/plugins/minify_html.ts'
// import nav from 'lume/plugins/nav.ts'
import pagefind from 'lume/plugins/pagefind.ts'
import unocss from 'lume/plugins/unocss.ts'
import options from '../uno.config.ts'
import lightningcss from 'lume/plugins/lightningcss.ts'
import { html } from './shared/html.ts'
import { styles } from './shared/styles.ts'
import { urls } from './shared/urls.ts'
import { navigation } from './shared/navigation.ts'
import { utils } from './shared/utils.ts'

export default () => (site: Lume.Site) =>
site
.use(html())
.use(slug())
.use(htmlHelper())
.use(slugHelper())
.use(data())
.use(jsx())
.use(theme({
color: '#099ad9',
filename: '/styles/tokens.css',
}))
.use(readInfo())
.use(metas())
.use(fff({
date: 'created', // TODO: published
getGitDate: true,
}))
// .use(date())
.use(sitemap())
.use(unocss({
options,
cssFile: '/uno.css',
reset: 'tailwind',
}))
.use(lightningcss())
.use(minifyHTML({ extensions: ['.html', '.css', '.js'] }))
// .use(nav())
.use(pagefind({
outputPath: '/search',
ui: { resetStyles: false },
}))
.use(html())
.use(navigation())
.use(styles())
.use(urls())
.use(utils())
// .preprocess(['.md'], (pages) =>
// pages.forEach((page) => {
// page.data.excerpt ??= (page.data.content as string).split(
Expand Down
8 changes: 8 additions & 0 deletions plugins/shared/html.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import metas from 'lume/plugins/metas.ts'
import minifyHTML from 'lume/plugins/minify_html.ts'

/** @see {@link https://lume.land/plugins/?status=disabled&html=on} */
export const html = () => (site: Lume.Site) =>
site
.use(metas())
.use(minifyHTML({ extensions: ['.html', '.css', '.js'] }))
13 changes: 13 additions & 0 deletions plugins/shared/navigation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// import nav from 'lume/plugins/nav.ts'
import pagefind from 'lume/plugins/pagefind.ts'
import sitemap from 'lume/plugins/sitemap.ts'

/** @see {@link https://lume.land/plugins/?status=disabled&nav=on} */
export const navigation = () => (site: Lume.Site) =>
site
// .use(nav())
.use(sitemap())
.use(pagefind({
outputPath: '/search',
ui: { resetStyles: false },
}))
13 changes: 13 additions & 0 deletions plugins/shared/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import unocss from 'lume/plugins/unocss.ts'
import lightningcss from 'lume/plugins/lightningcss.ts'
import options from '../../uno.config.ts'

/** @see {@link https://lume.land/plugins/?status=disabled&styles=on} */
export const styles = () => (site: Lume.Site) =>
site
.use(unocss({
options,
cssFile: '/uno.css',
reset: 'tailwind',
}))
.use(lightningcss())
39 changes: 0 additions & 39 deletions plugins/shared/unified.ts

This file was deleted.

4 changes: 4 additions & 0 deletions plugins/shared/urls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import resolveUrls from 'lume/plugins/resolve_urls.ts'

/** @see {@link https://lume.land/plugins/?status=disabled&urls=on} */
export const urls = () => (site: Lume.Site) => site.use(resolveUrls())
13 changes: 13 additions & 0 deletions plugins/shared/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// import date from 'lume/plugins/date.ts'
import fff from 'lume/plugins/fff.ts'
import readInfo from '../patched/reading_info.ts'

/** @see {@link https://lume.land/plugins/?status=disabled&utils=on} */
export const utils = () => (site: Lume.Site) =>
site
// .use(date())
.use(fff({
date: 'created', // TODO: published
getGitDate: true,
}))
.use(readInfo())
33 changes: 33 additions & 0 deletions plugins/unified/rehype.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { PluggableList } from 'lume/deps/remark.ts'
import rehypeSlug from 'npm:rehype-slug@5.1.0'
import rehypeAutolinkHeadings from 'npm:rehype-autolink-headings@7.1.0'
import rehypePrettyCode from 'npm:rehype-pretty-code@0.12.6'
// shikiji transformers
// import { transformerNotationDiff } from 'npm:shikiji-transformers@0.10.1'
import { transformerTwoslash } from 'npm:shikiji-twoslash@0.10.1'

export const rehypePlugins: PluggableList = [
// deno-lint-ignore no-explicit-any
rehypeSlug as any,
rehypeAutolinkHeadings,
[
rehypePrettyCode,
{
defaultLang: 'plaintext',
keepBackground: false,
theme: {
// light: 'material-theme-lighter',
// dark: 'material-theme-darker',
light: 'github-light',
dark: 'github-dark',
},
transformers: [
// transformerNotationDiff(),
transformerTwoslash(),
// transformerTwoslash({
// explicitTrigger: true,
// }),
],
},
],
]
6 changes: 6 additions & 0 deletions plugins/unified/remark.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { PluggableList } from 'lume/deps/remark.ts'
import remarkSmartyPants from 'npm:remark-smartypants@2.1.0'

export const remarkPlugins: PluggableList = [
remarkSmartyPants,
]

0 comments on commit 9414923

Please sign in to comment.