Skip to content

Commit

Permalink
vimwiki 특수 링크들을 처리, graph, tag 에서 해당 링크들이 처리되거나
Browse files Browse the repository at this point in the history
제거

- diary: -> diary/
- wn.[wikiname]:[path] -> 제거
  • Loading branch information
deptno committed Oct 26, 2023
1 parent 21b5cf1 commit 698c09d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/wiki/getGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DIR_WIKI } from './constant'
import { getNameFromLink } from './lib/getNameFromLink'
import { getVimwikiLinkBaseName } from './lib/getVimwikiLinkBaseName'
import { getMakrdownLinkBaseName } from './lib/getMarkdownLinkBaseName'
import { handleVimwikiPrefix } from './lib/handleVimwikiPrefix'

export const getGraph = () => {
if (_cache.current) {
Expand Down Expand Up @@ -36,6 +37,8 @@ export const getGraph = () => {
...vimwikiLinks,
...markdownLinks,
]
.map(handleVimwikiPrefix)
.filter(Boolean)

return {
source,
Expand Down
20 changes: 20 additions & 0 deletions apps/wiki/lib/handleVimwikiPrefix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export function handleVimwikiPrefix(link: string) {
if (link.startsWith('diary:')) {
// FIXME: diary:
// `diary:` prefix 는 `diary/` 와 달리 vimwiki 설정에 의해서 디렉토리명이 정해진다
// 환경값으로 받아야한다, default: diary
// 아래코드는 markdown 렌더링쪽에서 핸들링하는데 같은 로직으로 동작해야한다
// https://github.com/deptno/deptno.dev/blob/21b5cf10e3593f220311acb999830470cb4716b2/apps/wiki/lib/marked/link.ts#L9
return link.replace('diary:', 'diary/')
}
if (reWikiRef.test(link)) {
// TODO: wn.[WIKINAME]:[PATH] 패턴 처리
// 현재는 위키가 하나라서 추후 여기서 핸들링해야한다. 마크다운 렌더러 처리도 함께 진행 필요
// https://github.com/deptno/deptno.dev/blob/21b5cf10e3593f220311acb999830470cb4716b2/apps/wiki/lib/marked/link.ts#L22
return
}

return link
}

const reWikiRef = /wn\.\w+:\w+/

0 comments on commit 698c09d

Please sign in to comment.