@vuepress/core 2.0.0-beta.60 → 2.0.0-beta.61

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.ts CHANGED
@@ -45,6 +45,10 @@ type Page<ExtraPageData extends Record<any, any> = Record<never, never>, ExtraPa
45
45
  * Links of the page
46
46
  */
47
47
  links: MarkdownLink[];
48
+ /**
49
+ * Markdown env object of the page
50
+ */
51
+ markdownEnv: Record<string, unknown>;
48
52
  /**
49
53
  * Path of the page that inferred from file path
50
54
  *
@@ -674,15 +678,16 @@ declare const renderPageContent: ({ app, content, filePath, filePathRelative, op
674
678
  filePath: string | null;
675
679
  filePathRelative: string | null;
676
680
  options: PageOptions;
677
- }) => Promise<{
681
+ }) => {
678
682
  contentRendered: string;
679
683
  deps: string[];
684
+ markdownEnv: Record<string, unknown>;
680
685
  frontmatter: PageFrontmatter;
681
686
  headers: MarkdownHeader[];
682
687
  links: MarkdownLink[];
683
688
  sfcBlocks: MarkdownSfcBlocks;
684
689
  title: string;
685
- }>;
690
+ };
686
691
 
687
692
  /**
688
693
  * Resolve page component and related info
package/dist/index.js CHANGED
@@ -17,8 +17,10 @@ var preparePageComponent = async (app, page) => {
17
17
  await app.writeTemp(
18
18
  page.componentFilePathRelative,
19
19
  [
20
+ // #688: wrap the content of `<template>` with a `<div>` to avoid some potential issues of fragment component
20
21
  `${page.sfcBlocks.template?.tagOpen}<div>${page.sfcBlocks.template?.contentStripped}</div>${page.sfcBlocks.template?.tagClose}
21
22
  `,
23
+ // hoist `<script>`, `<style>` and other custom blocks
22
24
  page.sfcBlocks.script?.content,
23
25
  page.sfcBlocks.scriptSetup?.content,
24
26
  ...page.sfcBlocks.styles.map((item) => item.content),
@@ -181,7 +183,8 @@ var inferPagePath = ({
181
183
  };
182
184
 
183
185
  // src/page/renderPageContent.ts
184
- var renderPageContent = async ({
186
+ import { omit } from "@vuepress/shared";
187
+ var renderPageContent = ({
185
188
  app,
186
189
  content,
187
190
  filePath,
@@ -208,7 +211,8 @@ var renderPageContent = async ({
208
211
  styles: [],
209
212
  customBlocks: []
210
213
  },
211
- title = ""
214
+ title = "",
215
+ ...extraMarkdownEnv
212
216
  } = markdownEnv;
213
217
  return {
214
218
  contentRendered,
@@ -216,6 +220,14 @@ var renderPageContent = async ({
216
220
  frontmatter,
217
221
  headers,
218
222
  links,
223
+ markdownEnv: omit(
224
+ extraMarkdownEnv,
225
+ "base",
226
+ "content",
227
+ "filePath",
228
+ "filePathRelative",
229
+ "frontmatter"
230
+ ),
219
231
  sfcBlocks,
220
232
  title: frontmatter.title ?? title
221
233
  };
@@ -472,9 +484,10 @@ var createPage = async (app, options) => {
472
484
  frontmatter,
473
485
  headers,
474
486
  links,
487
+ markdownEnv,
475
488
  sfcBlocks,
476
489
  title
477
- } = await renderPageContent({
490
+ } = renderPageContent({
478
491
  app,
479
492
  content,
480
493
  filePath,
@@ -511,6 +524,7 @@ var createPage = async (app, options) => {
511
524
  });
512
525
  const { dataFilePath, dataFilePathRelative, dataFileChunkName } = resolvePageDataInfo({ app, htmlFilePathRelative, key });
513
526
  const page = {
527
+ // page data
514
528
  data: {
515
529
  key,
516
530
  path: path9,
@@ -519,23 +533,27 @@ var createPage = async (app, options) => {
519
533
  frontmatter,
520
534
  headers
521
535
  },
536
+ // base fields
522
537
  key,
523
538
  path: path9,
524
539
  title,
525
540
  lang,
526
541
  frontmatter,
527
542
  headers,
543
+ // extra fields
528
544
  content,
529
545
  contentRendered,
530
546
  date,
531
547
  deps,
532
548
  links,
549
+ markdownEnv,
533
550
  pathInferred,
534
551
  pathLocale,
535
552
  permalink,
536
553
  routeMeta,
537
554
  sfcBlocks,
538
555
  slug,
556
+ // file info
539
557
  filePath,
540
558
  filePathRelative,
541
559
  componentFilePath,
@@ -681,16 +699,20 @@ var createHookQueue = (name) => {
681
699
 
682
700
  // src/pluginApi/createPluginApiHooks.ts
683
701
  var createPluginApiHooks = () => ({
702
+ // life cycle hooks
684
703
  onInitialized: createHookQueue("onInitialized"),
685
704
  onPrepared: createHookQueue("onPrepared"),
686
705
  onWatched: createHookQueue("onWatched"),
687
706
  onGenerated: createHookQueue("onGenerated"),
707
+ // extends hooks
688
708
  extendsMarkdownOptions: createHookQueue("extendsMarkdownOptions"),
689
709
  extendsMarkdown: createHookQueue("extendsMarkdown"),
690
710
  extendsPageOptions: createHookQueue("extendsPageOptions"),
691
711
  extendsPage: createHookQueue("extendsPage"),
692
712
  extendsBundlerOptions: createHookQueue("extendsBundlerOptions"),
713
+ // client config file hooks
693
714
  clientConfigFile: createHookQueue("clientConfigFile"),
715
+ // bundler hooks
694
716
  alias: createHookQueue("alias"),
695
717
  define: createHookQueue("define")
696
718
  });
@@ -804,28 +826,33 @@ import { createRequire as createRequire2 } from "module";
804
826
  import { path as path8 } from "@vuepress/utils";
805
827
  var require3 = createRequire2(import.meta.url);
806
828
  var resolveAppOptions = ({
829
+ // site config
807
830
  base = "/",
808
831
  lang = "en-US",
809
832
  title = "",
810
833
  description = "",
811
834
  head = [],
812
835
  locales = {},
836
+ // directory config
813
837
  source,
814
838
  dest = path8.resolve(source, ".vuepress/dist"),
815
839
  temp = path8.resolve(source, ".vuepress/.temp"),
816
840
  cache = path8.resolve(source, ".vuepress/.cache"),
817
841
  public: publicDir = path8.resolve(source, ".vuepress/public"),
842
+ // dev config
818
843
  host = "0.0.0.0",
819
844
  port = 8080,
820
845
  open = false,
821
846
  templateDev = path8.normalize(
822
847
  require3.resolve("@vuepress/client/templates/dev.html")
823
848
  ),
849
+ // build config
824
850
  shouldPreload = true,
825
851
  shouldPrefetch = true,
826
852
  templateBuild = path8.normalize(
827
853
  require3.resolve("@vuepress/client/templates/build.html")
828
854
  ),
855
+ // common config
829
856
  bundler,
830
857
  debug: debug7 = false,
831
858
  markdown = {},
@@ -933,10 +960,12 @@ var createBaseApp = (config, isBuild = false) => {
933
960
  options,
934
961
  siteData,
935
962
  version,
963
+ // utils
936
964
  dir,
937
965
  env,
938
966
  pluginApi,
939
967
  writeTemp,
968
+ // methods
940
969
  use: (plugin) => appUse(app, plugin),
941
970
  init: () => appInit(app),
942
971
  prepare: () => appPrepare(app)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/core",
3
- "version": "2.0.0-beta.60",
3
+ "version": "2.0.0-beta.61",
4
4
  "description": "Core package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -27,11 +27,11 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "vue": "^3.2.45",
31
- "@vuepress/client": "2.0.0-beta.60",
32
- "@vuepress/markdown": "2.0.0-beta.60",
33
- "@vuepress/utils": "2.0.0-beta.60",
34
- "@vuepress/shared": "2.0.0-beta.60"
30
+ "vue": "^3.2.47",
31
+ "@vuepress/client": "2.0.0-beta.61",
32
+ "@vuepress/markdown": "2.0.0-beta.61",
33
+ "@vuepress/utils": "2.0.0-beta.61",
34
+ "@vuepress/shared": "2.0.0-beta.61"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"