@alloy-js/markdown 0.15.0 → 0.16.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/CHANGELOG.md +8 -0
- package/dist/src/components/Code.d.ts +12 -0
- package/dist/src/components/Code.d.ts.map +1 -0
- package/dist/src/components/Code.js +13 -0
- package/dist/src/components/Frontmatter.d.ts +19 -0
- package/dist/src/components/Frontmatter.d.ts.map +1 -0
- package/dist/src/components/Frontmatter.js +25 -0
- package/dist/src/components/index.d.ts +7 -1
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +7 -0
- package/dist/test/Code.test.d.ts +2 -0
- package/dist/test/Code.test.d.ts.map +1 -0
- package/dist/test/Code.test.js +37 -0
- package/dist/test/Frontmatter.test.d.ts +2 -0
- package/dist/test/Frontmatter.test.d.ts.map +1 -0
- package/dist/test/Frontmatter.test.js +37 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/src/components/Code.tsx +24 -0
- package/src/components/Frontmatter.tsx +32 -0
- package/src/components/index.ts +7 -0
- package/temp/api.json +1169 -1
- package/test/Code.test.tsx +37 -0
- package/test/Frontmatter.test.tsx +40 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog - @alloy-js/markdown
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#152](https://github.com/alloy-framework/alloy/pull/152) Add `<Code />` component
|
|
8
|
+
- [#149](https://github.com/alloy-framework/alloy/pull/149) Add `<FrontMatter />` component
|
|
9
|
+
|
|
10
|
+
|
|
3
11
|
|
|
4
12
|
|
|
5
13
|
## 0.15.0
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
export interface CodeProps {
|
|
3
|
+
/** Language of the code block */
|
|
4
|
+
lang?: string;
|
|
5
|
+
/** Body of the code block */
|
|
6
|
+
children?: Children;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Render a Markdown code block
|
|
10
|
+
*/
|
|
11
|
+
export declare function Code(props: CodeProps): Children;
|
|
12
|
+
//# sourceMappingURL=Code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Code.d.ts","sourceRoot":"","sources":["../../../src/components/Code.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,MAAM,WAAW,SAAS;IACxB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,YASpC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { List } from "@alloy-js/core";
|
|
3
|
+
/**
|
|
4
|
+
* Render a Markdown code block
|
|
5
|
+
*/
|
|
6
|
+
export function Code(props) {
|
|
7
|
+
const tripleBackticks = "```";
|
|
8
|
+
return _$createComponent(List, {
|
|
9
|
+
get children() {
|
|
10
|
+
return [_$memo(() => tripleBackticks + props.lang), _$memo(() => props.children), tripleBackticks];
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
export interface FrontmatterProps {
|
|
3
|
+
/** Js value to automatically serialize as yaml */
|
|
4
|
+
jsValue?: Record<string, unknown>;
|
|
5
|
+
children?: Children;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Create a frontmatter block for markdown files.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
*
|
|
12
|
+
* ```markdown
|
|
13
|
+
* ---
|
|
14
|
+
* title: "My Title"
|
|
15
|
+
* ---
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function Frontmatter(props: FrontmatterProps): Children;
|
|
19
|
+
//# sourceMappingURL=Frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Frontmatter.d.ts","sourceRoot":"","sources":["../../../src/components/Frontmatter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAGtD,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAUlD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { List } from "@alloy-js/core";
|
|
3
|
+
import { stringify } from "yaml";
|
|
4
|
+
/**
|
|
5
|
+
* Create a frontmatter block for markdown files.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* ```markdown
|
|
10
|
+
* ---
|
|
11
|
+
* title: "My Title"
|
|
12
|
+
* ---
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export function Frontmatter(props) {
|
|
16
|
+
return _$createComponent(List, {
|
|
17
|
+
get children() {
|
|
18
|
+
return ["---", _$memo(() => _$memo(() => !!props.jsValue)() ? stringify(props.jsValue).trim() : _$createComponent(List, {
|
|
19
|
+
get children() {
|
|
20
|
+
return props.children;
|
|
21
|
+
}
|
|
22
|
+
})), "---"];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./Code.jsx";
|
|
2
|
+
export * from "./Frontmatter.jsx";
|
|
3
|
+
export * from "./Heading.jsx";
|
|
4
|
+
export * from "./Link.jsx";
|
|
5
|
+
export * from "./List.jsx";
|
|
6
|
+
export * from "./Section.jsx";
|
|
7
|
+
export * from "./SourceFile.jsx";
|
|
2
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Code.test.d.ts","sourceRoot":"","sources":["../../test/Code.test.tsx"],"names":[],"mappings":"AACA,OAAO,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { List } from "@alloy-js/core";
|
|
3
|
+
import "@alloy-js/core/testing";
|
|
4
|
+
import { d } from "@alloy-js/core/testing";
|
|
5
|
+
import { expect, it } from "vitest";
|
|
6
|
+
import { Code } from "../src/components/Code.js";
|
|
7
|
+
import { mdTest } from "./utils.js";
|
|
8
|
+
it("renders with js value", () => {
|
|
9
|
+
const template = mdTest(_$createComponent(Code, {
|
|
10
|
+
lang: "ts",
|
|
11
|
+
children: "const foo = 123;\nconsole.log(foo);"
|
|
12
|
+
}));
|
|
13
|
+
expect(template).toRenderTo(d`
|
|
14
|
+
\`\`\`ts
|
|
15
|
+
const foo = 123;
|
|
16
|
+
console.log(foo);
|
|
17
|
+
\`\`\`
|
|
18
|
+
`);
|
|
19
|
+
});
|
|
20
|
+
it("renders with children", () => {
|
|
21
|
+
const template = mdTest(_$createComponent(Code, {
|
|
22
|
+
lang: "ts",
|
|
23
|
+
get children() {
|
|
24
|
+
return _$createComponent(List, {
|
|
25
|
+
get children() {
|
|
26
|
+
return [["const foo = 123;"], ["console.log(foo);"]];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
expect(template).toRenderTo(d`
|
|
32
|
+
\`\`\`ts
|
|
33
|
+
const foo = 123;
|
|
34
|
+
console.log(foo);
|
|
35
|
+
\`\`\`
|
|
36
|
+
`);
|
|
37
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Frontmatter.test.d.ts","sourceRoot":"","sources":["../../test/Frontmatter.test.tsx"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import "@alloy-js/core/testing";
|
|
3
|
+
import { d } from "@alloy-js/core/testing";
|
|
4
|
+
import { expect, it } from "vitest";
|
|
5
|
+
import { Frontmatter } from "../src/components/Frontmatter.js";
|
|
6
|
+
import { mdTest } from "./utils.js";
|
|
7
|
+
it("renders with js value", () => {
|
|
8
|
+
const template = mdTest(_$createComponent(Frontmatter, {
|
|
9
|
+
jsValue: {
|
|
10
|
+
title: "My Title",
|
|
11
|
+
tags: ["tag1", "tag2"]
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
expect(template).toRenderTo(d`
|
|
15
|
+
---
|
|
16
|
+
title: My Title
|
|
17
|
+
tags:
|
|
18
|
+
- tag1
|
|
19
|
+
- tag2
|
|
20
|
+
---
|
|
21
|
+
`);
|
|
22
|
+
});
|
|
23
|
+
it("renders with children", () => {
|
|
24
|
+
const template = mdTest(_$createComponent(Frontmatter, {
|
|
25
|
+
get children() {
|
|
26
|
+
return [[`title: My Title`], [`tags:`], [` - tag1`], [` - tag2`]];
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
expect(template).toRenderTo(d`
|
|
30
|
+
---
|
|
31
|
+
title: My Title
|
|
32
|
+
tags:
|
|
33
|
+
- tag1
|
|
34
|
+
- tag2
|
|
35
|
+
---
|
|
36
|
+
`);
|
|
37
|
+
});
|