-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
for whatever reason I can't fix Astro component
- Loading branch information
1 parent
bc7e934
commit 4315922
Showing
6 changed files
with
43 additions
and
38 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 |
---|---|---|
@@ -1,22 +1,26 @@ | ||
--- | ||
import { | ||
renderGraphviz, | ||
type RenderGraphvizOptions, | ||
} from "@beoe/rehype-graphviz"; | ||
import { getCache } from "@beoe/cache"; | ||
import { serialize } from "node:v8"; | ||
// I can't use internal modules - don't know why | ||
// import { processGraphvizSvg } from "@beoe/rehype-graphviz"; | ||
// import { getCache } from "@beoe/cache"; | ||
import { Graphviz } from "@hpcc-js/wasm"; | ||
const graphviz = await Graphviz.load(); | ||
const cache = await getCache(); | ||
// const cache = await getCache(); | ||
interface Props extends RenderGraphvizOptions {} | ||
interface Props { | ||
code: string; | ||
class?: string; | ||
} | ||
let svg: string; | ||
const cacheKey = serialize(Astro.props); | ||
svg = cache.get(cacheKey); | ||
if (svg === undefined) { | ||
svg = await renderGraphviz(Astro.props); | ||
cache.set(cacheKey, svg); | ||
} | ||
// const cacheKey = Astro.props.code; | ||
// svg = cache.get(cacheKey); | ||
// if (svg === undefined) { | ||
svg = graphviz.dot(Astro.props.code); | ||
// cache.set(cacheKey, svg); | ||
// } | ||
--- | ||
|
||
<Fragment set:html={svg} /> | ||
<figure class={`beoe graphviz ${Astro.props.class || ""}`}> | ||
<Fragment set:html={svg} /> | ||
</figure> |
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.