Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(plugins): named export #639

Merged
merged 65 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
978cb1a
refactor(plugins/base_path): named export
kwaa Aug 7, 2024
ffb3f5c
refactor(plugins/code_highlight): named export
kwaa Aug 7, 2024
329e813
refactor(plugins/date): named export
kwaa Aug 7, 2024
41c6268
refactor(plugins/decap_cms): named export
kwaa Aug 7, 2024
f89a676
refactor(plugins/esbuild): named export
kwaa Aug 7, 2024
07940cd
refactor(plugins/eta): named export
kwaa Aug 7, 2024
7354431
refactor(plugins/favicon): named export
kwaa Aug 7, 2024
214cefb
refactor(plugins/feed): named export
kwaa Aug 7, 2024
49c7f99
refactor(plugins/fff): named export
kwaa Aug 7, 2024
0c77c7d
refactor(plugins/filter_pages): named export
kwaa Aug 7, 2024
38316be
refactor(plugins/inline): named export
kwaa Aug 7, 2024
2419690
refactor(plugins/json): named export
kwaa Aug 7, 2024
e270188
refactor(plugins/jsx): named export
kwaa Aug 7, 2024
d1ea65f
refactor(plugins/jsx_preact): named export
kwaa Aug 7, 2024
480c84e
refactor(plugins/katex): named export
kwaa Aug 7, 2024
0c5baba
refactor(plugins/lightningcss): named export
kwaa Aug 7, 2024
cb03eec
refactor(plugins/liquid): named export
kwaa Aug 7, 2024
dfb2505
refactor(plugins/markdown): named export
kwaa Aug 7, 2024
e4de59d
refactor(plugins/mdx): named export
kwaa Aug 7, 2024
52591bb
refactor(plugins/metas): named export
kwaa Aug 7, 2024
5c87fda
refactor(plugins/minify_html): named export
kwaa Aug 7, 2024
32b7ed4
refactor(plugins/modify_urls): named export
kwaa Aug 7, 2024
b29ee23
refactor(plugins/modules): named export
kwaa Aug 7, 2024
b345570
refactor(plugins/multilanguage): named export
kwaa Aug 7, 2024
101a76b
refactor(plugins/nav): named export
kwaa Aug 7, 2024
3dc39fa
refactor(plugins/nunjucks): named export
kwaa Aug 7, 2024
07fb5cf
refactor(plugins/og_images): named export
kwaa Aug 7, 2024
fc03fe9
refactor(plugins/on_demand): named export
kwaa Aug 7, 2024
2d88c76
refactor(plugins/pagefind): named export
kwaa Aug 7, 2024
ed77966
refactor(plugins/paginate): named export
kwaa Aug 7, 2024
27c5771
refactor(plugins/picture): named export
kwaa Aug 7, 2024
ec5610b
refactor(plugins/postcss): named export
kwaa Aug 7, 2024
fd6315e
refactor(plugins/prism): named export
kwaa Aug 7, 2024
bbf4011
refactor(plugins/pug): named export
kwaa Aug 7, 2024
9141d2a
refactor(plugins/reading_info): named export
kwaa Aug 7, 2024
6e33886
refactor(plugins/redirects): named export
kwaa Aug 7, 2024
ec07a25
refactor(plugins/relations): named export
kwaa Aug 7, 2024
91bbb2d
refactor(plugins/relative_urls): named export
kwaa Aug 7, 2024
73c831e
refactor(plugins/remark): named export
kwaa Aug 7, 2024
2d092dd
refactor(plugins/resolve_urls): named export
kwaa Aug 7, 2024
d873980
refactor(plugins/robots): named export
kwaa Aug 7, 2024
54e38d2
refactor(plugins/sass): named export
kwaa Aug 7, 2024
5321e9b
refactor(plugins/search): named export
kwaa Aug 7, 2024
409fc2f
refactor(plugins/sheets): named export
kwaa Aug 7, 2024
ff8ef4b
refactor(plugins/sitemap): named export
kwaa Aug 7, 2024
e697116
refactor(plugins/slugify_urls): named export
kwaa Aug 7, 2024
8a30d9e
refactor(plugins/source_maps): named export
kwaa Aug 7, 2024
a654633
refactor(plugins/sri): named export
kwaa Aug 7, 2024
6d440ec
refactor(plugins/svgo): named export
kwaa Aug 7, 2024
f71e6f2
refactor(plugins/tailwindcss): named export
kwaa Aug 7, 2024
99a21d4
refactor(plugins/terser): named export
kwaa Aug 7, 2024
96220c1
refactor(plugins/toml): named export
kwaa Aug 7, 2024
16cc566
refactor(plugins/transform_images): named export
kwaa Aug 7, 2024
ab08ce7
refactor(plugins/unocss): named export
kwaa Aug 7, 2024
44fdcdd
refactor(plugins/url): named export
kwaa Aug 7, 2024
e6de609
refactor(plugins/vento): named export
kwaa Aug 7, 2024
7599a1e
refactor(plugins/yaml): named export
kwaa Aug 7, 2024
aff0313
chore: format code
kwaa Aug 7, 2024
856fb2b
refactor(plugins/attributes): named export
kwaa Aug 7, 2024
4834fe6
fix(plugins/toml): default export
kwaa Aug 7, 2024
1149cb7
fix(plugins/toml): format code
kwaa Aug 7, 2024
9f6d796
fix(plugins/yaml): default export
kwaa Aug 7, 2024
a7c745a
fix(tests/classname): update attributes import
kwaa Aug 7, 2024
86f916b
fix(tests/classname): fix import
kwaa Aug 7, 2024
14ab748
fix(plugins/nunjucks): uppercase
kwaa Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions plugins/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const escapeChars: Record<string, string> = {
* Plugin to provide helpers to manage attributes and class names of HTML elements
* @see https://lume.land/plugins/attributes/
*/
export default function () {
export function attributes() {
return (site: Site) => {
site.filter("attr", attributes);
site.filter("attr", attr);
site.filter("class", className);
};
}

export function attributes(values: unknown, ...validNames: string[]): string {
export function attr(values: unknown, ...validNames: string[]): string {
const attributes = new Map();

handleAttributes(attributes, values, validNames);
Expand Down Expand Up @@ -128,6 +128,8 @@ function isValid(name: string, validNames: string[]) {
return name && (!validNames.length || validNames.includes(name));
}

export default attributes;

/** Extends Helpers interface */
declare global {
namespace Lume {
Expand Down
4 changes: 3 additions & 1 deletion plugins/base_path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import type Site from "../core/site.ts";
* A plugin to prepend a base path to all internal URLs
* @see https://lume.land/plugins/base_path/
*/
export default function () {
export function basePath() {
return (site: Site) => {
site.use(modifyUrls({
fn: (url) => url.startsWith("/") ? site.url(url) : url,
}));
};
}

export default basePath;
4 changes: 3 additions & 1 deletion plugins/code_highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const defaults: Options = {
* A plugin to syntax-highlight code using the highlight.js library
* @see https://lume.land/plugins/code_highlight/
*/
export default function (userOptions?: Options) {
export function codeHighlight(userOptions?: Options) {
const options = merge(defaults, userOptions);
hljs.configure(options.options);

Expand Down Expand Up @@ -99,3 +99,5 @@ export default function (userOptions?: Options) {
}
};
}

export default codeHighlight;
4 changes: 3 additions & 1 deletion plugins/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const defaults: Options = {
* A plugin to format Date values
* @see https://lume.land/plugins/date/
*/
export default function (userOptions?: Options) {
export function date(userOptions?: Options) {
const options = merge(defaults, userOptions);

return (site: Site) => {
Expand Down Expand Up @@ -74,6 +74,8 @@ export default function (userOptions?: Options) {
};
}

export default date;

/** Extends Helpers interface */
declare global {
namespace Lume {
Expand Down
4 changes: 3 additions & 1 deletion plugins/decap_cms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const defaults: Options = {
* A plugin to use Decap CMS in Lume easily
* @see https://lume.land/plugins/decap_cms/
*/
export default function (userOptions?: Options) {
export function decapCMS(userOptions?: Options) {
const options = merge(defaults, userOptions);

return (site: Site) => {
Expand Down Expand Up @@ -157,3 +157,5 @@ declare global {
}
}
}

export default decapCMS;
4 changes: 3 additions & 1 deletion plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const defaults: Options = {
* A plugin to use esbuild in Lume
* @see https://lume.land/plugins/esbuild/
*/
export default function (userOptions?: Options) {
export function esbuild(userOptions?: Options) {
const options = merge(defaults, userOptions);

// Configure jsx automatically
Expand Down Expand Up @@ -392,3 +392,5 @@ function handleEsm(path: string, options: EsmOptions): string | undefined {

return url.href;
}

export default esbuild;
4 changes: 3 additions & 1 deletion plugins/eta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class EtaEngine implements Engine {
* A plugin to render Eta templates
* @see https://lume.land/plugins/eta/
*/
export default function (userOptions?: Options) {
export function eta(userOptions?: Options) {
return (site: Site) => {
const options = merge(
{ ...defaults, includes: site.options.includes },
Expand Down Expand Up @@ -129,3 +129,5 @@ export default function (userOptions?: Options) {
});
};
}

export default eta;
4 changes: 3 additions & 1 deletion plugins/favicon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface Favicon {
* A plugin to generate favicons from an SVG or PNG file
* @see https://lume.land/plugins/favicon/
*/
export default function (userOptions?: Options) {
export function favicon(userOptions?: Options) {
const options = merge(defaults, userOptions);

return (site: Site) => {
Expand Down Expand Up @@ -186,3 +186,5 @@ async function buildIco(

return image;
}

export default favicon;
4 changes: 3 additions & 1 deletion plugins/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const defaultGenerator = `Lume ${getCurrentVersion()}`;
* A plugin to generate RSS and JSON feeds
* @see https://lume.land/plugins/feed/
*/
export default function (userOptions?: Options) {
export function feed(userOptions?: Options) {
const options = merge(defaults, userOptions);

return (site: Site) => {
Expand Down Expand Up @@ -291,3 +291,5 @@ function clean(obj: Record<string, unknown>) {
Object.entries(obj).filter(([, value]) => value !== undefined),
);
}

export default feed;
4 changes: 3 additions & 1 deletion plugins/fff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const defaults: Options = {
* A plugin to transform frontmatter using FFF
* @see https://lume.land/plugins/fff/
*/
export default function (userOptions?: Partial<Options>) {
export function fff(userOptions?: Partial<Options>) {
const options = merge(defaults, userOptions);

return (site: Site) => {
Expand Down Expand Up @@ -66,6 +66,8 @@ export default function (userOptions?: Partial<Options>) {
};
}

export default fff;

/** Extends Data interface */
declare global {
namespace Lume {
Expand Down
4 changes: 3 additions & 1 deletion plugins/filter_pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const defaults: Options = {
* A plugin to filter pages
* @see https://lume.land/plugins/filter_pages/
*/
export default function (userOptions: Options) {
export function filterPages(userOptions: Options) {
const options = merge(defaults, userOptions);

return (site: Site) => {
Expand All @@ -38,3 +38,5 @@ export default function (userOptions: Options) {
});
};
}

export default filterPages;
4 changes: 3 additions & 1 deletion plugins/inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const cache = new Map();
* like images, JavaScript, CSS, SVG, etc.
* @see https://lume.land/plugins/inline/
*/
export default function (userOptions?: Options) {
export function inline(userOptions?: Options) {
const options = merge(defaults, userOptions);

return (site: Site) => {
Expand Down Expand Up @@ -242,3 +242,5 @@ async function getFileContent(

return content;
}

export default inline;
10 changes: 6 additions & 4 deletions plugins/json.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import json from "../core/loaders/json.ts";
import jsonLoader from "../core/loaders/json.ts";
import { merge } from "../core/utils/object.ts";

import type Site from "../core/site.ts";
Expand All @@ -22,14 +22,16 @@ export const defaults: Options = {
* Installed by default
* @see https://lume.land/plugins/json/
*/
export default function (userOptions?: Options) {
export function json(userOptions?: Options) {
const options = merge(defaults, userOptions);

return (site: Site) => {
site.loadData(options.extensions, json);
site.loadData(options.extensions, jsonLoader);
site.loadPages(options.extensions, {
pageSubExtension: options.pageSubExtension,
loader: json,
loader: jsonLoader,
});
};
}

export default json;
4 changes: 3 additions & 1 deletion plugins/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class JsxEngine implements Engine {
* A plugin to render JSX files using React
* @see https://lume.land/plugins/jsx/
*/
export default function (userOptions?: Options) {
export function jsx(userOptions?: Options) {
return (site: Site) => {
const options = merge(
{ ...defaults, includes: site.options.includes },
Expand All @@ -122,6 +122,8 @@ export default function (userOptions?: Options) {
};
}

export default jsx;

/** Extends Data interface */
declare global {
namespace Lume {
Expand Down
4 changes: 3 additions & 1 deletion plugins/jsx_preact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class PreactJsxEngine implements Engine {
* A plugin to render JSX files using Preact
* @see https://lume.land/plugins/jsx_preact/
*/
export default function (userOptions?: Options) {
export function jsxPreact(userOptions?: Options) {
return (site: Site) => {
const options = merge(
{ ...defaults, includes: site.options.includes },
Expand All @@ -118,6 +118,8 @@ export default function (userOptions?: Options) {
};
}

export default jsxPreact;

/** Extends HTMLAttributes interface */
declare global {
namespace preact.JSX {
Expand Down
8 changes: 5 additions & 3 deletions plugins/katex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { katex, KatexOptions } from "../deps/katex.ts";
import { katex as Katex, KatexOptions } from "../deps/katex.ts";
import { renderMathInElement } from "../deps/katex-auto-render/auto-render.ts";
import { merge } from "../core/utils/object.ts";

Expand Down Expand Up @@ -50,7 +50,7 @@ export const defaults: Options = {
* A plugin to render math equations using katex
* @see https://lume.land/plugins/katex/
*/
export default function (userOptions?: Options) {
export function katex(userOptions?: Options) {
const options = merge(defaults, userOptions);
return (site: Site) => {
site.process(options.extensions, (pages) => {
Expand All @@ -64,7 +64,7 @@ export default function (userOptions?: Options) {
document.querySelectorAll(options.cssSelector)
.forEach((element) => {
try {
const rendered = katex.renderToString(
const rendered = Katex.renderToString(
element.textContent,
options.options,
);
Expand Down Expand Up @@ -93,3 +93,5 @@ export default function (userOptions?: Options) {
});
};
}

export default katex;
4 changes: 3 additions & 1 deletion plugins/lightningcss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const defaults: Options = {
* A plugin to process CSS files with lightningcss
* @see https://lume.land/plugins/lightningcss/
*/
export default function (userOptions?: Options) {
export function lightningCSS(userOptions?: Options) {
return (site: Site) => {
const options = merge<Options>(
{ ...defaults, includes: site.options.includes },
Expand Down Expand Up @@ -161,3 +161,5 @@ export default function (userOptions?: Options) {
export function version(major: number, minor = 0, patch = 0): number {
return (major << 16) | (minor << 8) | patch;
}

export default lightningCSS;
4 changes: 3 additions & 1 deletion plugins/liquid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class LiquidEngine implements Engine {
* @see https://lume.land/plugins/liquid/
* @deprecated Use Vento or Nunjucks instead (see https://github.com/lumeland/lume/issues/600)
*/
export default function (userOptions?: Options) {
export function liquid(userOptions?: Options) {
return function (site: Site) {
const options = merge(
{ ...defaults, includes: site.options.includes },
Expand Down Expand Up @@ -249,6 +249,8 @@ function createCustomTagWithBody(fn: Helper): TagClass {
};
}

export default liquid;

/** Extends Helpers interface */
declare global {
namespace Lume {
Expand Down
4 changes: 3 additions & 1 deletion plugins/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class MarkdownEngine implements Engine {
* Installed by default
* @see https://lume.land/plugins/markdown
*/
export default function (userOptions?: Options) {
export function markdown(userOptions?: Options) {
const options = merge(defaults, userOptions);

if (options.useDefaultPlugins) {
Expand Down Expand Up @@ -140,6 +140,8 @@ export default function (userOptions?: Options) {
};
}

export default markdown;

/** Extends Helpers interface */
declare global {
namespace Lume {
Expand Down
4 changes: 3 additions & 1 deletion plugins/mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class MDXEngine implements Engine<string | { toString(): string }> {
* A plugin to render MDX files
* @see https://lume.land/plugins/mdx/
*/
export default function (userOptions?: Options) {
export function mdx(userOptions?: Options) {
return function (site: Site) {
const options = merge(
{ ...defaults, includes: site.options.includes },
Expand Down Expand Up @@ -160,6 +160,8 @@ export default function (userOptions?: Options) {
};
}

export default mdx;

/** Extends Helpers interface */
declare global {
namespace Lume {
Expand Down
4 changes: 3 additions & 1 deletion plugins/metas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const defaultGenerator = `Lume ${getCurrentVersion()}`;
* A plugin to insert meta tags for SEO and social media
* @see https://lume.land/plugins/metas/
*/
export default function (userOptions?: Options) {
export function metas(userOptions?: Options) {
const options = merge(defaults, userOptions);

return (site: Site) => {
Expand Down Expand Up @@ -178,6 +178,8 @@ function addMeta(
document.head.appendChild(document.createTextNode("\n"));
}

export default metas;

/** Extends Data interface */
declare global {
namespace Lume {
Expand Down
4 changes: 3 additions & 1 deletion plugins/minify_html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const defaults: Options = {
* A plugin to minify HTML, CSS & JavaScript files
* @see https://lume.land/plugins/minify_html/
*/
export default function (userOptions?: Options) {
export function minifyHTML(userOptions?: Options) {
const options = merge(defaults, userOptions);

const { extensions } = options;
Expand Down Expand Up @@ -63,3 +63,5 @@ export default function (userOptions?: Options) {
}
};
}

export default minifyHTML;
Loading