Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
CirnoV committed Jan 21, 2025
1 parent c80f700 commit 5934be6
Show file tree
Hide file tree
Showing 9 changed files with 1,530 additions and 1,201 deletions.
151 changes: 151 additions & 0 deletions app.config.timestamp_1737363465597.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// app.config.ts
import { readFile } from "node:fs/promises";

Check failure on line 2 in app.config.timestamp_1737363465597.js

View workflow job for this annotation

GitHub Actions / Lint code and MDX files

Run autofix to sort these imports!
import path from "node:path";
import remarkParamTree from "@portone-io/remark-param-tree";
import yaml from "@rollup/plugin-yaml";
import rehypeShiki from "@shikijs/rehype";
import { transformerMetaHighlight } from "@shikijs/transformers";
import { defineConfig } from "@solidjs/start/config";
import vinxiMdxPkg from "@vinxi/plugin-mdx";
import rehypeSlug from "rehype-slug";
import remarkFrontmatter from "remark-frontmatter";
import remarkGfm from "remark-gfm";
import unocss from "unocss/vite";
import { imagetools } from "vite-imagetools";

// src/misc/contentIndex.ts
var indexFilesMapping = {
ko: {
"\uC6D0 \uD398\uC774\uBA3C\uD2B8 \uC778\uD504\uB77C": "opi/ko/",
"\uD30C\uD2B8\uB108 \uC815\uC0B0 \uC790\uB3D9\uD654": "platform/ko/",
"\uB9B4\uB9AC\uC988 \uB178\uD2B8": "release-notes/(note)/",
"API & SDK": "sdk/ko/"

Check failure on line 22 in app.config.timestamp_1737363465597.js

View workflow job for this annotation

GitHub Actions / Lint code and MDX files

Insert `,`
},
blog: {
"\uAE30\uC220 \uBE14\uB85C\uADF8": "blog/"

Check failure on line 25 in app.config.timestamp_1737363465597.js

View workflow job for this annotation

GitHub Actions / Lint code and MDX files

Insert `,`
}

Check failure on line 26 in app.config.timestamp_1737363465597.js

View workflow job for this annotation

GitHub Actions / Lint code and MDX files

Insert `,`
};

// app.config.ts
var { default: vinxiMdx } = vinxiMdxPkg;
var app_config_default = defineConfig({
server: {
preset: "vercel",
prerender: {
routes: [
...Object.keys(indexFilesMapping).map(
(fileName) => `/content-index/${fileName}.json`

Check failure on line 37 in app.config.timestamp_1737363465597.js

View workflow job for this annotation

GitHub Actions / Lint code and MDX files

Insert `,`
),
"/blog/rss.xml"

Check failure on line 39 in app.config.timestamp_1737363465597.js

View workflow job for this annotation

GitHub Actions / Lint code and MDX files

Insert `,`
]

Check failure on line 40 in app.config.timestamp_1737363465597.js

View workflow job for this annotation

GitHub Actions / Lint code and MDX files

Insert `,`
},
rollupConfig: {
external: ["monaco-editor"]

Check failure on line 43 in app.config.timestamp_1737363465597.js

View workflow job for this annotation

GitHub Actions / Lint code and MDX files

Insert `,`
}

Check failure on line 44 in app.config.timestamp_1737363465597.js

View workflow job for this annotation

GitHub Actions / Lint code and MDX files

Insert `,`
},
extensions: ["ts", "tsx", "mdx"],
vite: () => ({
plugins: [
yaml(),
unocss(),
vinxiMdx.withImports({})({
jsx: true,
jsxImportSource: "solid-js",
providerImportSource: "solid-mdx",
remarkPlugins: [remarkFrontmatter, remarkGfm, remarkParamTree],
rehypePlugins: [
rehypeSlug,
[
rehypeShiki,
{
theme: "github-light",
fallbackLanguage: "text",
defaultLanguage: "text",
transformers: [
{
name: "remove-trailing-newline",
preprocess(code) {
if (code.endsWith("\n")) {
return code.slice(0, -1);
}
return code;
}

Check failure on line 72 in app.config.timestamp_1737363465597.js

View workflow job for this annotation

GitHub Actions / Lint code and MDX files

Insert `,`
},
transformerMetaHighlight(),
{
name: "line-number-meta",
code(node) {
if (this.options.meta?.__raw?.includes("showLineNumber")) {
this.addClassToHast(node, "line-numbers");
}
}
},
{
name: "title",
pre(node) {
const matches = /title="([^"]+)"/.exec(
this.options.meta?.__raw ?? ""
);
if (matches?.[1]) {
node.children.unshift({
type: "element",
tagName: "div",
properties: {
className: ["title"]
},
children: [{ type: "text", value: matches[1] }]
});
}
}
}
]
}
]
]
}),
imagetools({
defaultDirectives: (url) => {
const extname = path.extname(url.pathname);
if (
// formats supported by Sharp (https://sharp.pixelplumbing.com/#formats)
[
".png",
".jpg",
".jpeg",
".webp",
".gif",
".avif",
".tiff",
".tif",
".svg"
].includes(extname)
) {
return new URLSearchParams([
["as", "picture"],
["format", "webp"],
...url.searchParams.entries()
]);
} else
return url.searchParams;
}
}),
{
name: "base64-loader",
async transform(_, id) {
const [path2, query] = id.split("?");
if (query !== "base64" || !path2)
return null;
const data = await readFile(path2);
const base64 = data.toString("base64");
return `export default '${base64}';`;
}
}
]
}),
solid: {
exclude: ["./src/misc/opengraph/**/*"]
}
});
export {
app_config_default as default
};
151 changes: 151 additions & 0 deletions app.config.timestamp_1737363499924.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// app.config.ts
import { readFile } from "node:fs/promises";
import path from "node:path";
import remarkParamTree from "@portone-io/remark-param-tree";
import yaml from "@rollup/plugin-yaml";
import rehypeShiki from "@shikijs/rehype";
import { transformerMetaHighlight } from "@shikijs/transformers";
import { defineConfig } from "@solidjs/start/config";
import vinxiMdxPkg from "@vinxi/plugin-mdx";
import rehypeSlug from "rehype-slug";
import remarkFrontmatter from "remark-frontmatter";
import remarkGfm from "remark-gfm";
import unocss from "unocss/vite";
import { imagetools } from "vite-imagetools";

// src/misc/contentIndex.ts
var indexFilesMapping = {
ko: {
"\uC6D0 \uD398\uC774\uBA3C\uD2B8 \uC778\uD504\uB77C": "opi/ko/",
"\uD30C\uD2B8\uB108 \uC815\uC0B0 \uC790\uB3D9\uD654": "platform/ko/",
"\uB9B4\uB9AC\uC988 \uB178\uD2B8": "release-notes/(note)/",
"API & SDK": "sdk/ko/"
},
blog: {
"\uAE30\uC220 \uBE14\uB85C\uADF8": "blog/"
}
};

// app.config.ts
var { default: vinxiMdx } = vinxiMdxPkg;
var app_config_default = defineConfig({
server: {
preset: "vercel",
prerender: {
routes: [
...Object.keys(indexFilesMapping).map(
(fileName) => `/content-index/${fileName}.json`
),
"/blog/rss.xml"
]
},
rollupConfig: {
external: ["monaco-editor"]
}
},
extensions: ["ts", "tsx", "mdx"],
vite: () => ({
plugins: [
yaml(),
unocss(),
vinxiMdx.withImports({})({
jsx: true,
jsxImportSource: "solid-js",
providerImportSource: "solid-mdx",
remarkPlugins: [remarkFrontmatter, remarkGfm, remarkParamTree],
rehypePlugins: [
rehypeSlug,
[
rehypeShiki,
{
theme: "github-light",
fallbackLanguage: "text",
defaultLanguage: "text",
transformers: [
{
name: "remove-trailing-newline",
preprocess(code) {
if (code.endsWith("\n")) {
return code.slice(0, -1);
}
return code;
}
},
transformerMetaHighlight(),
{
name: "line-number-meta",
code(node) {
if (this.options.meta?.__raw?.includes("showLineNumber")) {
this.addClassToHast(node, "line-numbers");
}
}
},
{
name: "title",
pre(node) {
const matches = /title="([^"]+)"/.exec(
this.options.meta?.__raw ?? ""
);
if (matches?.[1]) {
node.children.unshift({
type: "element",
tagName: "div",
properties: {
className: ["title"]
},
children: [{ type: "text", value: matches[1] }]
});
}
}
}
]
}
]
]
}),
imagetools({
defaultDirectives: (url) => {
const extname = path.extname(url.pathname);
if (
// formats supported by Sharp (https://sharp.pixelplumbing.com/#formats)
[
".png",
".jpg",
".jpeg",
".webp",
".gif",
".avif",
".tiff",
".tif",
".svg"
].includes(extname)
) {
return new URLSearchParams([
["as", "picture"],
["format", "webp"],
...url.searchParams.entries()
]);
} else
return url.searchParams;
}
}),
{
name: "base64-loader",
async transform(_, id) {
const [path2, query] = id.split("?");
if (query !== "base64" || !path2)
return null;
const data = await readFile(path2);
const base64 = data.toString("base64");
return `export default '${base64}';`;
}
}
]
}),
solid: {
exclude: ["./src/misc/opengraph/**/*"]
}
});
export {
app_config_default as default
};
1 change: 1 addition & 0 deletions packages/remark-param-tree/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"test": "vitest"
},
"dependencies": {
"es-toolkit": "^1.31.0",
"mdast-util-from-markdown": "^2.0.1",
"mdast-util-mdx": "^3.0.0",
"mdast-util-to-string": "^4.0.0",
Expand Down
Loading

0 comments on commit 5934be6

Please sign in to comment.