-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,530 additions
and
1,201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.