@soubiran/vite 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { t as Options } from "./types-D_cQ9r48.mjs";
1
+ import { t as Options } from "./types-DeADD3vz.mjs";
2
2
  import { PluginOption } from "vite";
3
3
 
4
4
  //#region src/index.d.ts
5
- declare function soubiran(title: string, hostname: string, options: Options): PluginOption[];
5
+ declare function soubiran(options: Options): PluginOption[];
6
6
  //#endregion
7
7
  export { soubiran as default };
package/dist/index.mjs CHANGED
@@ -650,7 +650,7 @@ function generateJsonApi(outDir, categories, logger) {
650
650
  }
651
651
  //#endregion
652
652
  //#region src/plugins/api.ts
653
- function api_default(categories = []) {
653
+ function api_default(options = {}) {
654
654
  let config;
655
655
  return {
656
656
  name: "api",
@@ -659,10 +659,11 @@ function api_default(categories = []) {
659
659
  },
660
660
  closeBundle() {
661
661
  if (this.environment.name !== "client") return;
662
- if (categories.length === 0) return;
662
+ if (!options.categories) return;
663
+ if (options.categories.length === 0) return;
663
664
  const time = Date.now();
664
665
  config.logger.info(yellow("Generate API files"));
665
- generateJsonApi(config.build.outDir, categories, config.logger);
666
+ generateJsonApi(config.build.outDir, options.categories, config.logger);
666
667
  config.logger.info(green(`✓ generated in ${Date.now() - time}ms`));
667
668
  }
668
669
  };
@@ -737,7 +738,7 @@ function generateMeta(outDir, hostname, logger) {
737
738
  }
738
739
  //#endregion
739
740
  //#region src/plugins/meta.ts
740
- function meta_default(hostname) {
741
+ function meta_default(options) {
741
742
  let config;
742
743
  return {
743
744
  name: "meta",
@@ -748,7 +749,7 @@ function meta_default(hostname) {
748
749
  if (this.environment.name !== "client") return;
749
750
  const time = Date.now();
750
751
  config.logger.info(yellow("Generate meta.json"));
751
- generateMeta(config.build.outDir, hostname, config.logger);
752
+ generateMeta(config.build.outDir, options.hostname, config.logger);
752
753
  config.logger.info(green(`✓ generated in ${Date.now() - time}ms`));
753
754
  }
754
755
  };
@@ -846,7 +847,7 @@ function generateSitemap(outDir, hostname, routes) {
846
847
  }
847
848
  //#endregion
848
849
  //#region src/plugins/sitemap.ts
849
- function sitemap_default(hostname) {
850
+ function sitemap_default(options) {
850
851
  const routes = /* @__PURE__ */ new Set();
851
852
  let config;
852
853
  return {
@@ -858,7 +859,7 @@ function sitemap_default(hostname) {
858
859
  return renderedHTML;
859
860
  },
860
861
  onFinished() {
861
- generateSitemap(config.build.outDir, hostname, Array.from(routes));
862
+ generateSitemap(config.build.outDir, options.hostname, Array.from(routes));
862
863
  }
863
864
  } };
864
865
  },
@@ -869,7 +870,7 @@ function sitemap_default(hostname) {
869
870
  }
870
871
  //#endregion
871
872
  //#region src/plugins/ssg.ts
872
- function ssg_default() {
873
+ function ssg_default(options = {}) {
873
874
  return {
874
875
  name: "soubiran:ssg",
875
876
  config() {
@@ -878,84 +879,90 @@ function ssg_default() {
878
879
  };
879
880
  }
880
881
  //#endregion
881
- //#region src/index.ts
882
- function soubiran(title, hostname, options) {
883
- return [
884
- options.router === false ? void 0 : router({
885
- extensions: [".vue", ".md"],
886
- routesFolder: "pages",
887
- dts: "src/route-map.d.ts",
888
- extendRoute(route) {
889
- const path = route.components.get("default");
890
- if (!path) return;
891
- if (path.endsWith(".vue") && options.router && options.router.extractPage) route.addToMeta({ frontmatter: { page: options.router.extractPage(path) } });
892
- if (path.endsWith(".md")) {
893
- const { data } = matter(readFileSync(path, "utf-8"));
894
- route.addToMeta({ frontmatter: data });
895
- }
896
- }
897
- }),
898
- vue({ include: vueIncludePatterns }),
899
- ui({
900
- autoImport: {
901
- dts: "src/auto-imports.d.ts",
902
- dirs: ["src/composables"],
903
- imports: [
904
- "vue",
905
- "vue-router",
906
- "@vueuse/core",
907
- unheadVueComposablesImports,
908
- {
909
- from: "tailwind-variants",
910
- imports: ["tv"]
911
- },
912
- soubiranComposablesImports
913
- ]
914
- },
915
- components: {
916
- include: componentIncludePatterns,
917
- dts: "src/components.d.ts",
918
- resolvers: [soubiranResolver()]
919
- },
920
- ui: { colors: { neutral: "neutral" } }
921
- }),
922
- options.markdown === false ? void 0 : markdown({
923
- headEnabled: true,
924
- wrapperClasses: soubiranWrapperClasses,
925
- transforms: options.markdown?.options?.transforms ?? {},
926
- wrapperComponent: options.markdown?.options?.wrapperComponent,
927
- markdownItSetup: markdownRulesFactory(hostname),
928
- frontmatterPreprocess: markdownFrontmatterFactory({
929
- title,
930
- hostname,
931
- extractPage: options.markdown.extractPage,
932
- assertRules: options.seo?.assert?.rules,
933
- getPageConfig: options.seo?.structuredData?.pageConfig
934
- })
935
- }),
936
- fonts({ google: { families: [
937
- {
938
- name: "DM Sans",
939
- styles: "ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000"
940
- },
941
- {
942
- name: "DM Mono",
943
- styles: "ital,wght@0,300;0,400;0,500;1,300;1,400;1,500"
944
- },
945
- {
946
- name: "Sofia Sans",
947
- styles: "ital,wght@0,1..1000;1,1..1000"
882
+ //#region src/factory.ts
883
+ function factory(options) {
884
+ const plugins = [];
885
+ if (options.router !== false) plugins.push(router({
886
+ extensions: [".vue", ".md"],
887
+ routesFolder: "pages",
888
+ dts: "src/route-map.d.ts",
889
+ extendRoute(route) {
890
+ const path = route.components.get("default");
891
+ if (!path) return;
892
+ if (path.endsWith(".vue") && options.router && options.router.extractPage) route.addToMeta({ frontmatter: { page: options.router.extractPage(path) } });
893
+ if (path.endsWith(".md")) {
894
+ const { data } = matter(readFileSync(path, "utf-8"));
895
+ route.addToMeta({ frontmatter: data });
948
896
  }
949
- ] } }),
950
- icons({ autoInstall: true }),
951
- config_default(),
952
- ssg_default(),
953
- meta_default(hostname),
954
- api_default(options.api?.categories),
955
- raw_markdown_default(),
956
- sitemap_default(hostname),
957
- promise_default()
897
+ }
898
+ }));
899
+ plugins.push(vue({ include: vueIncludePatterns }));
900
+ const imports = [
901
+ "vue",
902
+ "@vueuse/core",
903
+ {
904
+ from: "tailwind-variants",
905
+ imports: ["tv"]
906
+ },
907
+ unheadVueComposablesImports,
908
+ soubiranComposablesImports
958
909
  ];
910
+ if (options.router !== false) imports.push("vue-router");
911
+ plugins.push(ui({
912
+ autoImport: {
913
+ dts: "src/auto-imports.d.ts",
914
+ dirs: ["src/utils", "src/composables"],
915
+ imports
916
+ },
917
+ components: {
918
+ include: componentIncludePatterns,
919
+ dts: "src/components.d.ts",
920
+ resolvers: [soubiranResolver()]
921
+ },
922
+ ui: { colors: { neutral: "neutral" } }
923
+ }));
924
+ if (options.markdown !== false) plugins.push(markdown({
925
+ headEnabled: true,
926
+ wrapperClasses: soubiranWrapperClasses,
927
+ transforms: options.markdown?.options?.transforms ?? {},
928
+ wrapperComponent: options.markdown?.options?.wrapperComponent,
929
+ markdownItSetup: markdownRulesFactory(options.hostname),
930
+ frontmatterPreprocess: markdownFrontmatterFactory({
931
+ title: options.title,
932
+ hostname: options.hostname,
933
+ extractPage: options.markdown.extractPage,
934
+ assertRules: options.seo?.assert?.rules,
935
+ getPageConfig: options.seo?.structuredData?.pageConfig
936
+ })
937
+ }));
938
+ plugins.push(fonts({ google: { families: [
939
+ {
940
+ name: "DM Sans",
941
+ styles: "ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000"
942
+ },
943
+ {
944
+ name: "DM Mono",
945
+ styles: "ital,wght@0,300;0,400;0,500;1,300;1,400;1,500"
946
+ },
947
+ {
948
+ name: "Sofia Sans",
949
+ styles: "ital,wght@0,1..1000;1,1..1000"
950
+ }
951
+ ] } }));
952
+ plugins.push(icons({ autoInstall: true }));
953
+ plugins.push(config_default());
954
+ if (options.ssg !== false) plugins.push(ssg_default());
955
+ if (options.meta !== false) plugins.push(meta_default({ hostname: options.meta?.hostname || options.hostname }));
956
+ if (options.api !== false) plugins.push(api_default({ categories: options.api?.categories }));
957
+ if (options.markdown !== false) plugins.push(raw_markdown_default());
958
+ if (options.sitemap !== false) plugins.push(sitemap_default({ hostname: options.sitemap?.hostname || options.hostname }));
959
+ plugins.push(promise_default());
960
+ return plugins;
961
+ }
962
+ //#endregion
963
+ //#region src/index.ts
964
+ function soubiran(options) {
965
+ return factory(options);
959
966
  }
960
967
  //#endregion
961
968
  export { soubiran as default };
@@ -16,9 +16,29 @@ interface StructuredDataPageConfig {
16
16
  breadcrumbItems?: BreadcrumbItem[];
17
17
  }
18
18
  //#endregion
19
+ //#region src/plugins/api.d.ts
20
+ interface ApiOptions {
21
+ categories?: string[];
22
+ }
23
+ //#endregion
24
+ //#region src/plugins/meta.d.ts
25
+ interface MetaOptions {
26
+ hostname: string;
27
+ }
28
+ //#endregion
29
+ //#region src/plugins/sitemap.d.ts
30
+ interface SitemapOptions {
31
+ hostname: string;
32
+ }
33
+ //#endregion
34
+ //#region src/plugins/ssg.d.ts
35
+ interface SsgOptions {}
36
+ //#endregion
19
37
  //#region src/types.d.ts
20
38
  type ExtractPage = (id: string) => string | null;
21
39
  interface Options$1 {
40
+ title: string;
41
+ hostname: string;
22
42
  router?: {
23
43
  extractPage?: ExtractPage;
24
44
  } | false;
@@ -34,9 +54,10 @@ interface Options$1 {
34
54
  pageConfig?: (page: string | null, frontmatter: Record<string, any>) => StructuredDataPageConfig;
35
55
  };
36
56
  };
37
- api?: {
38
- categories?: string[];
39
- };
57
+ ssg?: SsgOptions | false;
58
+ meta?: MetaOptions | false;
59
+ api?: ApiOptions | false;
60
+ sitemap?: SitemapOptions | false;
40
61
  }
41
62
  //#endregion
42
63
  export { StructuredDataPageConfig as n, BreadcrumbItem as r, Options$1 as t };
package/dist/types.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as StructuredDataPageConfig, r as BreadcrumbItem, t as Options } from "./types-D_cQ9r48.mjs";
1
+ import { n as StructuredDataPageConfig, r as BreadcrumbItem, t as Options } from "./types-DeADD3vz.mjs";
2
2
  export { BreadcrumbItem, Options, StructuredDataPageConfig };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soubiran/vite",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.6.2",
5
5
  "author": "Estéban Soubiran <esteban@soubiran.dev>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/Barbapapazes",
@@ -62,7 +62,7 @@
62
62
  "vite": "^8.0.1",
63
63
  "vite-ssg": "^28.3.0",
64
64
  "vue-router": "^4.6.3",
65
- "@soubiran/ui": "0.6.0"
65
+ "@soubiran/ui": "0.6.2"
66
66
  },
67
67
  "devDependencies": {
68
68
  "tsdown": "^0.21.4"