* Add new lint rule `prefer-path-get-value` * Add new rule * Apply fix * Ingore projects in benchmark * Add comment
20 lines
512 B
JavaScript
20 lines
512 B
JavaScript
import { hardline } from "../document/builders.js";
|
|
import printFrontMatter from "../utils/front-matter/print.js";
|
|
|
|
function embed(path) {
|
|
const { node } = path;
|
|
|
|
if (node.type === "front-matter") {
|
|
return async (textToDoc) => {
|
|
const doc = await printFrontMatter(node, textToDoc);
|
|
return doc ? [doc, hardline] : undefined;
|
|
};
|
|
}
|
|
}
|
|
|
|
// `front-matter` only available on `css-root`
|
|
embed.getVisitorKeys = (node) =>
|
|
node.type === "css-root" ? ["frontMatter"] : [];
|
|
|
|
export default embed;
|