Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Feb 20, 2024
1 parent 7bf86a7 commit 3d51270
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 6 additions & 10 deletions apps/www/mdsx.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { readFileSync } from "fs";
import { join, resolve } from "path";
import { fileURLToPath } from "url";
import prettier from "prettier";
import prettier from "@prettier/sync";
import rehypePrettyCode from "rehype-pretty-code";
import rehypeSlug from "rehype-slug";
import { codeImport } from "remark-code-import";
Expand Down Expand Up @@ -86,11 +86,13 @@ export const mdsxConfig = defineConfig({
* itself and checking for it in the code block, but that's not something we need
* at the moment.
*
* @returns {MdastTransformer}
*/
function remarkRemovePrettierIgnore() {
return async (tree) => {
visit(tree, "code", (node) => {
node.value = node.value
// @ts-expect-error - not dealing with this rn
.replaceAll("<!-- prettier-ignore -->\n", "")
.replaceAll("// prettier-ignore\n", "");
});
Expand Down Expand Up @@ -148,7 +150,7 @@ const styles = [
];

export function rehypeComponentExample() {
return async (tree) => {
return (tree) => {
const nameRegex = /name="([^"]+)"/;
visit(tree, (node, index, parent) => {
if (node?.type === "raw" && node?.value?.startsWith("<ComponentPreview")) {
Expand All @@ -166,10 +168,7 @@ export function rehypeComponentExample() {
let sourceCode = getComponentSourceFileContent(src);
if (!sourceCode) return;
// @ts-expect-error - not dealing with this rn
sourceCode = sourceCode.replaceAll(
`@/registry/${style.name}/`,
"$lib/components/"
);
sourceCode = sourceCode.replaceAll(`@/registry/${style.name}/`, "$lib/components/");

const sourceCodeNode = u("element", {
tagName: "pre",
Expand Down Expand Up @@ -246,10 +245,7 @@ function getComponentSourceFileContent(src = "") {
// Read the source file.
const filePath = join(process.cwd(), newSrc);

const formattedSource = prettier.format(
readFileSync(filePath, "utf-8"),
codeBlockPrettierConfig
);
const formattedSource = prettier.format(readFileSync(filePath, "utf-8"), codeBlockPrettierConfig);

return formattedSource;
}
2 changes: 2 additions & 0 deletions apps/www/src/content/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ description: Latest updates and announcements.
import { Steps, Callout, ComponentPreview } from '$components/docs'
</script>

## February 2024

## January 2024 - Part 2

We've added a new component to the project, [Carousel](/docs/components/carousel).
Expand Down

0 comments on commit 3d51270

Please sign in to comment.