{"id":21233233,"url":"https://github.com/luma-dev/my-unified","last_synced_at":"2025-06-29T11:37:33.736Z","repository":{"id":219620116,"uuid":"747801066","full_name":"luma-dev/my-unified","owner":"luma-dev","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-07T11:40:44.000Z","size":291,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-07T12:24:37.518Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luma-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-01-24T17:04:35.000Z","updated_at":"2025-06-07T11:40:09.000Z","dependencies_parsed_at":"2024-02-10T16:44:14.502Z","dependency_job_id":"b25b6a25-aaf0-4011-8f7a-136d07246173","html_url":"https://github.com/luma-dev/my-unified","commit_stats":null,"previous_names":["luma-dev/my-unified"],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/luma-dev/my-unified","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luma-dev%2Fmy-unified","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luma-dev%2Fmy-unified/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luma-dev%2Fmy-unified/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luma-dev%2Fmy-unified/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luma-dev","download_url":"https://codeload.github.com/luma-dev/my-unified/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luma-dev%2Fmy-unified/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262588474,"owners_count":23333179,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T23:56:43.401Z","updated_at":"2025-06-29T11:37:33.704Z","avatar_url":"https://github.com/luma-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @luma-dev/my-unified\n\n\u003e [!WARNING]\n\u003e このパッケージが提供するプラグインは私のユースケースに特化したものなので，直接使うのは推奨しません．  \n\u003e The plugins provided by this package are specific to my use case, so I do not recommend using them directly!\n\n下記の通りCC0でライセンスしていますので，コピペしてご利用することをおすすめします．\n\n## ライセンス\n\n[MIT](https://github.com/luma-dev/my-unified?tab=MIT-2-ov-file)と[CC0](https://github.com/luma-dev/my-unified?tab=CC0-1.0-1-ov-file)でライセンスされています\n\n## インストール\n\n```bash\nnpm i @luma-dev/my-unified\n```\n\n## Next.jsでの設定例\n\nESM (package.jsonのtype=module) 前提での設定例．プラグインの指定順は結果に影響を与えるため注意．\n\n```js\n// next.config.js\nimport remarkGfm from \"remark-gfm\";\nimport remarkFrontmatter from \"remark-frontmatter\";\nimport remarkMath from \"remark-math\";\n\nimport createMDX from \"@next/mdx\";\n\nimport rehypeKatex from \"@luma-dev/my-unified/rehype-katex\";\nimport remarkTerm from \"@luma-dev/my-unified/remark-term\";\nimport remarkMeta from \"@luma-dev/my-unified/remark-meta\";\nimport rehypeReplaceText from \"@luma-dev/my-unified/rehype-replace-text\";\nimport rehypeSave from \"@luma-dev/my-unified/rehype-save\";\nimport rehypeCounter from \"@luma-dev/my-unified/rehype-counter\";\nimport rehypeAddSlug from \"@luma-dev/my-unified/rehype-add-slug\";\nimport rehypeWrap from \"@luma-dev/my-unified/rehype-wrap\";\nimport rehypeCleanInternal from \"@luma-dev/my-unified/rehype-clean-internal\";\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  pageExtensions: [\"js\", \"jsx\", \"mdx\", \"ts\", \"tsx\"],\n};\n\nconst withMDX = createMDX({\n  options: {\n    rehypePlugins: [\n      remarkGfm,\n      rehypeReplaceText,\n      rehypeKatex,\n      rehypeSave,\n      rehypeCounter,\n\n      rehypeAddSlug,\n      rehypeWrap,\n\n      rehypeCleanInternal,\n    ],\n    remarkPlugins: [remarkFrontmatter, remarkMath, remarkTerm, remarkMeta],\n  },\n});\n\nexport default withMDX(nextConfig);\n```\n\n```tsx\n// mdx-components.tsx\nimport type {\n  LumaMdxLayoutProps,\n  LumaKatexProps,\n  LumaCounterProps,\n  LumaLoadedProps,\n  LumaTermProps,\n} from \"@luma-type/my-unified/types\";\n\nexport function useMDXComponents(components: MDXComponents): MDXComponents {\n  return {\n    ...components,\n    LumaMdxLayout: (props: LumaMdxLayoutProps) =\u003e (\n      /* Replace with your component */\n      \u003cdiv\u003e\n        \u003cdiv\u003eLumaMdxLayout\u003c/div\u003e\n        {props.children}\n      \u003c/div\u003e\n    ),\n    LumaKatex: (props: LumaKatexProps) =\u003e (\n      /* Replace with your component */\n      \u003cdiv\u003e\n        \u003cdiv\u003eLumaKatex\u003c/div\u003e\n        {props.children}\n      \u003c/div\u003e\n    ),\n    LumaCounter: (props: LumaCounterProps) =\u003e (\n      /* Replace with your component */\n      \u003cdiv\u003e\n        \u003cdiv\u003eLumaCounter\u003c/div\u003e\n        {props.children}\n      \u003c/div\u003e\n    ),\n    LumaLoaded: (props: LumaLoadedProps) =\u003e (\n      /* Replace with your component */\n      \u003cdiv\u003e\n        \u003cdiv\u003eLumaLoaded\u003c/div\u003e\n        {props.children}\n      \u003c/div\u003e\n    ),\n    LumaTerm: (props: LumaTermProps) =\u003e (\n      /* Replace with your component */\n      \u003cdiv\u003e\n        \u003cdiv\u003eLumaTerm\u003c/div\u003e\n        {props.children}\n      \u003c/div\u003e\n    ),\n  };\n}\n```\n\n## rehype-add-slug\n\n各ヘディングに対し，slug化したそのテキストを属性として渡し，それより上位のヘディングのslugも属性に付与するプラグイン\n\n```ts\nimport rehypeAddSlug from \"@luma-dev/my-unified/rehype-add-slug\";\n```\n\n例: 以下の入力に対し，\n\n```md\n# hello world\n\n## 1. getting started\n\n## 2. install\n\n## 3. uninstall\n\n# description\n\n## 1. something\n\n## 2. other\n```\n\n以下のように変換される\n\n```js\n\u003ch1 slug=\"hello_world\"\u003ehello world\u003c/h1\u003e\n\u003ch2 lastH1Slug=\"hello_world\" slug=\"1.getting_started\"\u003e1. getting started\u003c/h1\u003e\n\u003ch2 lastH1Slug=\"hello_world\" slug=\"2.install\"\u003e2. install\u003c/h1\u003e\n...\n```\n\n## rehype-replace-text\n\n句点読点を統一する．「，」「．」を「、」「。」に置き換えるプラグイン．\n\n```ts\nimport rehypeReplaceText from \"@luma-dev/my-unified/rehype-replace-text\";\n```\n\n例: 以下の入力に対し，\n\n```md\nこんにちは，ねこだよ．\n```\n\n以下のように変換される\n\n```md\nこんにちは、ねこだよ。\n```\n\n## remark-term\n\n用語を参照する記法を追加します．mdx前提です．\n\n```ts\nimport remarkTerm from \"@luma-dev/my-unified/remark-term\";\n```\n\n例: 以下の入力に対し，\n\n```mdx\n[@逆元]を考える．\n\n{/* 以下のようにすると途中で定義を変えられる */}\n\n\u003cDefMapImp 逆元=\"群の逆元\" /\u003e\n\n[@逆元]を考える．\n\n{/* 通常のリンクでは先頭の@をエスケープする必要がある */}\n[\\@これもリンク](https://example.com)だよ．\n```\n\n以下のように変換される\n\n```mdx\n\u003cLumaTerm\n  rawTermRef=\"逆元\"\n  termRef=\"逆元\"\n  gotBy=\"raw\"\n  indexInPage={0}\n  totalInPage={1}\n/\u003e\nを考える．\n\n\u003cLumaTerm\n  rawTermRef=\"逆元\"\n  termRef=\"群の逆元\"\n  gotBy=\"imp\"\n  indexInPage={0}\n  totalInPage={1}\n/\u003e\nを考える．\n```\n\n`indexInPage` は `termRef` が何個目に出るか， `totalInPage` は `termRef` が全体で何個あるか，をページ内で集計したもの．\n\n`DefMapImp` (implicit) の他に `DefMapExp` (explicit) でも書き換えられる．\nそれらの振る舞いの違いは利用側に委ねられている．\n[remark-frontmatter](https://github.com/remarkjs/remark-frontmatter)を入れた状態でfrontmatterのYAMLで `DefMapExp` か `DefMapImp` を使うと同様に初期化できる\n\n```mdx\n---\nDefMapExp:\nDefMapImp:\n  逆元: 行列の逆元\n---\n```\n\n## rehype-katex\n\n- 下記に対する検出をして共通の定義を差し込むなどを行う\n  - `\u003cKatex\u003e`, `\u003cKatexDef\u003e` で囲まれたテキスト\n  - `katex`, `katex-def` という言語で設定したコードブロック\n  - `katex-save` という言語で設定したコードブロックを `\u003cSave\u003e` で囲って変換する\n\n```ts\nimport rehypeKatex from \"@luma-dev/my-unified/rehype-katex\";\n```\n\n## rehype-wrap\n\n`\u003cLumaMdxLayout\u003e` で囲ってメタ情報を属性として入れるプラグイン．\n\n```ts\nimport rehypeKatex from \"@luma-dev/my-unified/rehype-wrap\";\n```\n\n例: 以下の入力に対し，\n\n```mdx\n---\nfoo: bar\n---\n\nhello\n```\n\n以下のように変換される\n\n```mdx\n\u003cLumaMdxLayout meta={{ foo: 'bar' }} file={...} toc={...} headers={...}\u003e\nhello\n\u003c/LumaMdxLayout\u003e\n```\n\n- `file` はmdxファイル自体の情報\n- `toc` はヘッダをまとめた情報\n  - `[{ tag: 'h1', level: 1, index: 0, titleComponent: ..., titleText: '...', slug: '...', children: [...] }, ...]` という形式になる\n- `headers` はヘッダの中身のレンダー済みコンポーネントのリスト\n  - `toc` のインデックス情報がこちらのリストのインデックスに対応する\n\n## remark-save\n\n`\u003cSave $name\u003e` で囲ってページローカル保存（コンパイル時）， `[$name]` で呼び出しができるプラグイン．\n\n```ts\nimport remarkSave from \"@luma-dev/my-unified/remark-save\";\n```\n\n例: 以下の入力に対し，\n\n```mdx\n\u003cSave $who\u003eworld\u003c/Save\u003e\nhello [$who]\n```\n\n以下のように変換される\n\n```mdx\nhello world\n```\n\n## rehype-meta\n\n`\u003c_luma_internal_meta\u003e` というタグのコンポーネントと一緒にメタデータを入れておくプラグイン．\nrehype-wrapでメタデータを入れるために必要．\n\n```ts\nimport rehypeSave from \"@luma-dev/my-unified/rehype-meta\";\n```\n\n## rehype-clean-internal\n\n`\u003c_luma_internal_*\u003e` などを消すプラグイン．\n\n```ts\nimport rehypeCleanInternal from \"@luma-dev/my-unified/rehype-clean-internal\";\n```\n\n## rehype-code-meta\n\n`\u003ccode\u003e` に `.data.meta` をプロパティとして加えるプラグイン．\n\n```ts\nimport rehypeCodeMeta from \"@luma-dev/my-unified/rehype-code-meta\";\n```\n\n## rehype-counter\n\n`[#name]` という記法で，その名前ごとに登場回数をカウントして `\u003cLumaCounter index={0} total={3} /\u003e` のように置き換える． `\u003cC $name anyAttr=\"something\" /\u003e` のように書くことでそれ以降のその名前のカウンタに属性を一律で付与できる．\n\n```ts\nimport rehypeCounter from \"@luma-dev/my-unified/rehype-counter\";\n```\n\n例: 以下の入力に対し，\n\n```mdx\n\u003cC template=\"%0.\" /\u003e\n\n[#]フォークを持つ\n[#]ナイフを持つ\n[#]切る\n```\n\n以下のように変換される\n\n```mdx\n\u003cLumaCounter index={0} total={3} template=\"%0.\" /\u003e\nフォークを持つ\n\u003cLumaCounter index={1} total={3} template=\"%0.\" /\u003e\nナイフを持つ\n\u003cLumaCounter index={2} total={3} template=\"%0.\" /\u003e\n切る\n```\n\n`template` をどう扱うか，などは `LumaCounter` を実装することで意味を与えることになる．\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluma-dev%2Fmy-unified","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluma-dev%2Fmy-unified","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluma-dev%2Fmy-unified/lists"}