@nuxtjs/mdc 0.14.0 → 0.15.0

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/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
3
  "configKey": "mdc",
4
- "version": "0.14.0",
4
+ "version": "0.15.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
@@ -64,10 +64,18 @@ const props = defineProps({
64
64
  unwrap: {
65
65
  type: [Boolean, String],
66
66
  default: false
67
+ },
68
+ /**
69
+ * Async Data Unique Key
70
+ * @default `hash(props.value)`
71
+ */
72
+ cacheKey: {
73
+ type: String,
74
+ default: undefined
67
75
  }
68
76
  })
69
77
 
70
- const key = computed(() => hash(props.value))
78
+ const key = computed(() => props.cacheKey ?? hash(props.value))
71
79
 
72
80
  const { data, refresh, error } = await useAsyncData(key.value, async () => {
73
81
  if (typeof props.value !== 'string') {
@@ -73,8 +73,17 @@ export const createMarkdownParser = async (inlineOptions = {}) => {
73
73
  const processor = await createParseProcessor(inlineOptions);
74
74
  return async function parse(md, { fileOptions } = {}) {
75
75
  const { content, data: frontmatter } = await parseFrontMatter(md);
76
- const processedFile = await processor.process({ ...fileOptions, value: content, data: frontmatter });
77
- const result = processedFile.result;
76
+ const cwd = typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : "/tmp";
77
+ const processedFile = await new Promise((resolve, reject) => {
78
+ processor.process({ cwd, ...fileOptions, value: content, data: frontmatter }, (err, file) => {
79
+ if (err) {
80
+ reject(err);
81
+ } else {
82
+ resolve(file);
83
+ }
84
+ });
85
+ });
86
+ const result = processedFile?.result;
78
87
  const data = Object.assign(
79
88
  inlineOptions.contentHeading !== false ? contentHeading(result.body) : {},
80
89
  frontmatter,
@@ -16,6 +16,7 @@ export function mdcRemark(options) {
16
16
  * @see https://github.com/rehypejs/rehype-remark/blob/main/lib/index.js#L37ckages/remark/lib/index.js#L100
17
17
  */
18
18
  document: true,
19
+ newlines: true,
19
20
  ...options,
20
21
  handlers: {
21
22
  ...mdcRemarkHandlers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxtjs/mdc",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Nuxt MDC module",
5
5
  "repository": "nuxt-modules/mdc",
6
6
  "license": "MIT",