[ci] format

This commit is contained in:
natemoo-re 2022-08-05 23:58:09 +00:00 committed by fredkbot
parent c039ea93a1
commit 367cdd9ed8
5 changed files with 18 additions and 11 deletions

View file

@ -22,7 +22,9 @@ describe('Astro Markdown - frontmatter injection', () => {
it('rehype supports custom vfile data - reading time', async () => { it('rehype supports custom vfile data - reading time', async () => {
const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json')); const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json'));
const readingTimes = frontmatterByPage.map((frontmatter = {}) => frontmatter.injectedReadingTime); const readingTimes = frontmatterByPage.map(
(frontmatter = {}) => frontmatter.injectedReadingTime
);
expect(readingTimes.length).to.be.greaterThan(0); expect(readingTimes.length).to.be.greaterThan(0);
for (let readingTime of readingTimes) { for (let readingTime of readingTimes) {
expect(readingTime).to.not.be.null; expect(readingTime).to.not.be.null;
@ -32,7 +34,9 @@ describe('Astro Markdown - frontmatter injection', () => {
it('overrides injected frontmatter with user frontmatter', async () => { it('overrides injected frontmatter with user frontmatter', async () => {
const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json')); const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json'));
const readingTimes = frontmatterByPage.map((frontmatter = {}) => frontmatter.injectedReadingTime?.text); const readingTimes = frontmatterByPage.map(
(frontmatter = {}) => frontmatter.injectedReadingTime?.text
);
const titles = frontmatterByPage.map((frontmatter = {}) => frontmatter.title); const titles = frontmatterByPage.map((frontmatter = {}) => frontmatter.title);
expect(titles).to.contain('Overridden title'); expect(titles).to.contain('Overridden title');
expect(readingTimes).to.contain('1000 min read'); expect(readingTimes).to.contain('1000 min read');

View file

@ -1,8 +1,7 @@
import { name as isValidIdentifierName } from 'estree-util-is-identifier-name';
import type { VFile } from 'vfile';
import type { MdxjsEsm } from 'mdast-util-mdx';
import type { MarkdownAstroData } from 'astro'; import type { MarkdownAstroData } from 'astro';
import type { Data } from 'vfile'; import { name as isValidIdentifierName } from 'estree-util-is-identifier-name';
import type { MdxjsEsm } from 'mdast-util-mdx';
import type { Data, VFile } from 'vfile';
import { jsToTreeNode } from './utils.js'; import { jsToTreeNode } from './utils.js';
export function remarkInitializeAstroData() { export function remarkInitializeAstroData() {

View file

@ -1,7 +1,6 @@
import { compile as mdxCompile, nodeTypes } from '@mdx-js/mdx'; import { compile as mdxCompile, nodeTypes } from '@mdx-js/mdx';
import mdxPlugin, { Options as MdxRollupPluginOptions } from '@mdx-js/rollup'; import mdxPlugin, { Options as MdxRollupPluginOptions } from '@mdx-js/rollup';
import type { AstroIntegration, AstroConfig } from 'astro'; import type { AstroConfig, AstroIntegration } from 'astro';
import { remarkInitializeAstroData, rehypeApplyFrontmatterExport } from './astro-data-utils.js';
import { parse as parseESM } from 'es-module-lexer'; import { parse as parseESM } from 'es-module-lexer';
import rehypeRaw from 'rehype-raw'; import rehypeRaw from 'rehype-raw';
import remarkGfm from 'remark-gfm'; import remarkGfm from 'remark-gfm';
@ -10,6 +9,7 @@ import remarkShikiTwoslash from 'remark-shiki-twoslash';
import remarkSmartypants from 'remark-smartypants'; import remarkSmartypants from 'remark-smartypants';
import { VFile } from 'vfile'; import { VFile } from 'vfile';
import type { Plugin as VitePlugin } from 'vite'; import type { Plugin as VitePlugin } from 'vite';
import { rehypeApplyFrontmatterExport, remarkInitializeAstroData } from './astro-data-utils.js';
import rehypeCollectHeadings from './rehype-collect-headings.js'; import rehypeCollectHeadings from './rehype-collect-headings.js';
import remarkPrism from './remark-prism.js'; import remarkPrism from './remark-prism.js';
import { getFileInfo, parseFrontmatter } from './utils.js'; import { getFileInfo, parseFrontmatter } from './utils.js';

View file

@ -22,7 +22,9 @@ describe('MDX frontmatter injection', () => {
it('rehype supports custom vfile data - reading time', async () => { it('rehype supports custom vfile data - reading time', async () => {
const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json')); const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json'));
const readingTimes = frontmatterByPage.map((frontmatter = {}) => frontmatter.injectedReadingTime); const readingTimes = frontmatterByPage.map(
(frontmatter = {}) => frontmatter.injectedReadingTime
);
expect(readingTimes.length).to.be.greaterThan(0); expect(readingTimes.length).to.be.greaterThan(0);
for (let readingTime of readingTimes) { for (let readingTime of readingTimes) {
expect(readingTime).to.not.be.null; expect(readingTime).to.not.be.null;
@ -32,7 +34,9 @@ describe('MDX frontmatter injection', () => {
it('overrides injected frontmatter with user frontmatter', async () => { it('overrides injected frontmatter with user frontmatter', async () => {
const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json')); const frontmatterByPage = JSON.parse(await fixture.readFile('/glob.json'));
const readingTimes = frontmatterByPage.map((frontmatter = {}) => frontmatter.injectedReadingTime?.text); const readingTimes = frontmatterByPage.map(
(frontmatter = {}) => frontmatter.injectedReadingTime?.text
);
const titles = frontmatterByPage.map((frontmatter = {}) => frontmatter.title); const titles = frontmatterByPage.map((frontmatter = {}) => frontmatter.title);
expect(titles).to.contain('Overridden title'); expect(titles).to.contain('Overridden title');
expect(readingTimes).to.contain('1000 min read'); expect(readingTimes).to.contain('1000 min read');

View file

@ -7,13 +7,13 @@ import rehypeExpressions from './rehype-expressions.js';
import rehypeIslands from './rehype-islands.js'; import rehypeIslands from './rehype-islands.js';
import rehypeJsx from './rehype-jsx.js'; import rehypeJsx from './rehype-jsx.js';
import remarkEscape from './remark-escape.js'; import remarkEscape from './remark-escape.js';
import { remarkInitializeAstroData } from './remark-initialize-astro-data.js';
import remarkMarkAndUnravel from './remark-mark-and-unravel.js'; import remarkMarkAndUnravel from './remark-mark-and-unravel.js';
import remarkMdxish from './remark-mdxish.js'; import remarkMdxish from './remark-mdxish.js';
import remarkPrism from './remark-prism.js'; import remarkPrism from './remark-prism.js';
import scopedStyles from './remark-scoped-styles.js'; import scopedStyles from './remark-scoped-styles.js';
import remarkShiki from './remark-shiki.js'; import remarkShiki from './remark-shiki.js';
import remarkUnwrap from './remark-unwrap.js'; import remarkUnwrap from './remark-unwrap.js';
import { remarkInitializeAstroData } from './remark-initialize-astro-data.js';
import rehypeRaw from 'rehype-raw'; import rehypeRaw from 'rehype-raw';
import rehypeStringify from 'rehype-stringify'; import rehypeStringify from 'rehype-stringify';