Artemy Egorov 572531a02d
Dev (#207)
* feat: big badge configuration

* fix: remove google fonts

* fix(plugins, server): remove cdn

* ci: fix format ignore

* feat(server): json configuration

* feat: add search route for adding in browser

* fix: add arm arch

* fix: docker action

* fix: engines fallback

* doc: change logo

* doc: fix logo margin

* doc: update version

* doc: change layout

* dev: add dependabot groups

* dev: fix dependabot and format
2024-07-24 07:45:59 +00:00

38 lines
862 B
TypeScript

import { Middleware, JSX } from '@txtdot/sdk';
const Highlight = new Middleware(
'Highlight',
'Highlights code with highlight.js only when needed',
['*']
);
Highlight.use(async (input, ro, out) => {
if (out.content.indexOf('<code') !== -1)
return {
...out,
content: <Highlighter content={out.content} />,
};
return out;
});
function Highlighter({ content }: { content: string }) {
return (
<>
<style>
@import "/static/third-party/styles/atom-one-light.min.css"; @import
"/static/third-party/styles/atom-one-dark.min.css" screen and
(prefers-color-scheme: dark);
</style>
<script
src="/static/third-party/scripts/highlight.min.js"
type="text/javascript"
/>
<script>hljs.highlightAll();</script>
{content}
</>
);
}
export default Highlight;