astro-accelerator-utils 0.1.3 → 0.1.4
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/index.d.mts +3 -3
- package/index.mjs +4 -4
- package/lib/v1/markdown.d.mts +20 -0
- package/lib/v1/markdown.mjs +47 -0
- package/lib/v1/posts.mjs +1 -0
- package/package.json +1 -1
- package/lib/markdown.d.mts +0 -18
- package/lib/markdown.mjs +0 -45
package/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { DateFormatter } from "./lib/v1/dates.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { Markdown } from "./lib/v1/markdown.mjs";
|
|
3
3
|
import { Posts } from "./lib/v1/posts.mjs";
|
|
4
|
+
import { UrlFormatter } from "./lib/v1/urls.mjs";
|
|
4
5
|
import * as Cache from "./lib/cache.mjs";
|
|
5
6
|
import * as PostQueries from "./lib/postQueries.mjs";
|
|
6
7
|
import * as PostFiltering from "./lib/postFiltering.mjs";
|
|
7
8
|
import * as PostOrdering from "./lib/postOrdering.mjs";
|
|
8
9
|
import * as PostPaging from "./lib/postPaging.mjs";
|
|
9
10
|
import * as FooterMenu from "./lib/footerMenu.mjs";
|
|
10
|
-
import * as Markdown from "./lib/markdown.mjs";
|
|
11
11
|
import * as Navigation from "./lib/navigation.mjs";
|
|
12
12
|
import * as Taxonomy from "./lib/taxonomy.mjs";
|
|
13
|
-
export { DateFormatter,
|
|
13
|
+
export { DateFormatter, Markdown, Posts, UrlFormatter, Cache, PostQueries, PostFiltering, PostOrdering, PostPaging, FooterMenu, Navigation, Taxonomy };
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DateFormatter } from './lib/v1/dates.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { Markdown } from './lib/v1/markdown.mjs';
|
|
3
3
|
import { Posts } from './lib/v1/posts.mjs';
|
|
4
|
+
import { UrlFormatter } from './lib/v1/urls.mjs';
|
|
4
5
|
|
|
5
6
|
import * as Cache from './lib/cache.mjs';
|
|
6
7
|
import * as PostQueries from './lib/postQueries.mjs';
|
|
@@ -8,21 +9,20 @@ import * as PostFiltering from './lib/postFiltering.mjs';
|
|
|
8
9
|
import * as PostOrdering from './lib/postOrdering.mjs';
|
|
9
10
|
import * as PostPaging from './lib/postPaging.mjs';
|
|
10
11
|
import * as FooterMenu from './lib/footerMenu.mjs';
|
|
11
|
-
import * as Markdown from './lib/markdown.mjs';
|
|
12
12
|
import * as Navigation from './lib/navigation.mjs';
|
|
13
13
|
import * as Taxonomy from './lib/taxonomy.mjs';
|
|
14
14
|
|
|
15
15
|
export {
|
|
16
16
|
DateFormatter,
|
|
17
|
-
|
|
17
|
+
Markdown,
|
|
18
18
|
Posts,
|
|
19
|
+
UrlFormatter,
|
|
19
20
|
Cache,
|
|
20
21
|
PostQueries,
|
|
21
22
|
PostFiltering,
|
|
22
23
|
PostOrdering,
|
|
23
24
|
PostPaging,
|
|
24
25
|
FooterMenu,
|
|
25
|
-
Markdown,
|
|
26
26
|
Navigation,
|
|
27
27
|
Taxonomy
|
|
28
28
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class Markdown {
|
|
2
|
+
/**
|
|
3
|
+
* Converts markdown to HTML without wrapping in a <p>
|
|
4
|
+
* @param {string} markdown
|
|
5
|
+
* @returns {Promise<string>}
|
|
6
|
+
*/
|
|
7
|
+
getInlineHtmlFrom(markdown: string): Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Converts markdown to HTML
|
|
10
|
+
* @param {string} markdown
|
|
11
|
+
* @returns {Promise<string>}
|
|
12
|
+
*/
|
|
13
|
+
getHtmlFrom(markdown: string): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Converts markdown to plain text
|
|
16
|
+
* @param {string} markdown
|
|
17
|
+
* @returns {Promise<string>}
|
|
18
|
+
*/
|
|
19
|
+
getTextFrom(markdown: string): Promise<string>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { unified } from 'unified';
|
|
2
|
+
import remarkParse from 'remark-parse';
|
|
3
|
+
import remarkRehype from 'remark-rehype'
|
|
4
|
+
import rehypeStringify from 'rehype-stringify';
|
|
5
|
+
|
|
6
|
+
export class Markdown {
|
|
7
|
+
/**
|
|
8
|
+
* Converts markdown to HTML without wrapping in a <p>
|
|
9
|
+
* @param {string} markdown
|
|
10
|
+
* @returns {Promise<string>}
|
|
11
|
+
*/
|
|
12
|
+
async getInlineHtmlFrom(markdown) {
|
|
13
|
+
let html = await this.getHtmlFrom(markdown);
|
|
14
|
+
|
|
15
|
+
// There may be a better way to unwrap this... maybe a visitor
|
|
16
|
+
if (html.substring(0, 3) == '<p>' && html.substring(html.length - 4) == '</p>') {
|
|
17
|
+
html = html.substring(3, html.length - 4);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return html;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Converts markdown to HTML
|
|
25
|
+
* @param {string} markdown
|
|
26
|
+
* @returns {Promise<string>}
|
|
27
|
+
*/
|
|
28
|
+
async getHtmlFrom(markdown) {
|
|
29
|
+
const vfile = await unified()
|
|
30
|
+
.use(remarkParse)
|
|
31
|
+
.use(remarkRehype)
|
|
32
|
+
.use(rehypeStringify)
|
|
33
|
+
.process(markdown)
|
|
34
|
+
|
|
35
|
+
return String(vfile);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Converts markdown to plain text
|
|
40
|
+
* @param {string} markdown
|
|
41
|
+
* @returns {Promise<string>}
|
|
42
|
+
*/
|
|
43
|
+
async getTextFrom(markdown) {
|
|
44
|
+
const html = await this.getInlineHtmlFrom(markdown);
|
|
45
|
+
return html.replace(/<.*?>/g, '');
|
|
46
|
+
}
|
|
47
|
+
}
|
package/lib/v1/posts.mjs
CHANGED
package/package.json
CHANGED
package/lib/markdown.d.mts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts markdown to HTML without wrapping in a <p>
|
|
3
|
-
* @param {string} markdown
|
|
4
|
-
* @returns {Promise<string>}
|
|
5
|
-
*/
|
|
6
|
-
export function getInlineHtmlFrom(markdown: string): Promise<string>;
|
|
7
|
-
/**
|
|
8
|
-
* Converts markdown to HTML
|
|
9
|
-
* @param {string} markdown
|
|
10
|
-
* @returns {Promise<string>}
|
|
11
|
-
*/
|
|
12
|
-
export function getHtmlFrom(markdown: string): Promise<string>;
|
|
13
|
-
/**
|
|
14
|
-
* Converts markdown to plain text
|
|
15
|
-
* @param {string} markdown
|
|
16
|
-
* @returns {Promise<string>}
|
|
17
|
-
*/
|
|
18
|
-
export function getTextFrom(markdown: string): Promise<string>;
|
package/lib/markdown.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { unified } from 'unified';
|
|
2
|
-
import remarkParse from 'remark-parse';
|
|
3
|
-
import remarkRehype from 'remark-rehype'
|
|
4
|
-
import rehypeStringify from 'rehype-stringify';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Converts markdown to HTML without wrapping in a <p>
|
|
8
|
-
* @param {string} markdown
|
|
9
|
-
* @returns {Promise<string>}
|
|
10
|
-
*/
|
|
11
|
-
export async function getInlineHtmlFrom(markdown) {
|
|
12
|
-
let html = await getHtmlFrom(markdown);
|
|
13
|
-
|
|
14
|
-
// There may be a better way to unwrap this... maybe a visitor
|
|
15
|
-
if (html.substring(0, 3) == '<p>' && html.substring(html.length - 4) == '</p>') {
|
|
16
|
-
html = html.substring(3, html.length - 4);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return html;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Converts markdown to HTML
|
|
24
|
-
* @param {string} markdown
|
|
25
|
-
* @returns {Promise<string>}
|
|
26
|
-
*/
|
|
27
|
-
export async function getHtmlFrom(markdown) {
|
|
28
|
-
const vfile = await unified()
|
|
29
|
-
.use(remarkParse)
|
|
30
|
-
.use(remarkRehype)
|
|
31
|
-
.use(rehypeStringify)
|
|
32
|
-
.process(markdown)
|
|
33
|
-
|
|
34
|
-
return String(vfile);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Converts markdown to plain text
|
|
39
|
-
* @param {string} markdown
|
|
40
|
-
* @returns {Promise<string>}
|
|
41
|
-
*/
|
|
42
|
-
export async function getTextFrom(markdown) {
|
|
43
|
-
const html = await getInlineHtmlFrom(markdown);
|
|
44
|
-
return html.replace(/<.*?>/g, '');
|
|
45
|
-
}
|