Skip to content

Commit

Permalink
update: fix missing backlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMonad committed Jan 19, 2024
1 parent caaa680 commit 9e1366f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
6 changes: 5 additions & 1 deletion docs/specs/vectorgraphics/frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sidebar_class_name: show

<a href="#backlinks" className="badge backlinks">
<span className="label">Backlinks</span>
<span className="value">5</span>
<span className="value">6</span>
</a>

</div>
Expand Down Expand Up @@ -998,6 +998,10 @@ Value

<ul className="backlinks-list">

<li className="backlink">
<Link to='/specs/vectorgraphics/overview#frames'>Overview.frames</Link>
</li>

<li className="backlink">
<Link to='/specs/vectorgraphics/frame#childobjects'>Frame.childObjects</Link>
</li>
Expand Down
6 changes: 5 additions & 1 deletion docs/specs/vectorgraphics/symbol-master.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sidebar_class_name: show

<a href="#backlinks" className="badge backlinks">
<span className="label">Backlinks</span>
<span className="value">5</span>
<span className="value">6</span>
</a>

</div>
Expand Down Expand Up @@ -994,6 +994,10 @@ Value

<ul className="backlinks-list">

<li className="backlink">
<Link to='/specs/vectorgraphics/overview#references'>Overview.references</Link>
</li>

<li className="backlink">
<Link to='/specs/vectorgraphics/frame#childobjects'>Frame.childObjects</Link>
</li>
Expand Down
24 changes: 18 additions & 6 deletions lib/jsonschema2md/markdownBuilder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function build({

return acc
}, {})

const root_backlinks = root_nodes.reduce((acc, cur) => {
const path = cur.path.slice(2).join(".")
const refObj = jp.value(schemas[0].properties, path)
Expand All @@ -62,16 +63,27 @@ export default function build({

const merged_backlinks = Object.keys(backlinks).reduce(
(acc, cur) => {
acc[cur] = backlinks[cur]
const isDuplicated = acc[cur]

if (isDuplicated) {
acc[cur] = [...acc[cur], ...backlinks[cur]]
} else {
acc[cur] = backlinks[cur]
}

return acc
},
Object.keys(root_backlinks).reduce(
(acc, cur) => {
acc[cur] = acc[cur].map(
(x) =>
"Overview.properties." +
(x.split("properties.")[1] ?? x.split(".")[0])
)
acc[cur] = acc[cur]
.filter((x) => {
return !/\w+\.\w+(\.\w+)*\.properties/.test(x)
})
.map(
(x) =>
"Overview.properties." +
(x.split("properties.")[1] ?? x.split(".")[0])
)

return acc
},
Expand Down

0 comments on commit 9e1366f

Please sign in to comment.