Skip to content

Commit

Permalink
[TechDocs] Bug fixes and cleanups (#3599)
Browse files Browse the repository at this point in the history
* Fixed issue with some internal doc links reloading the page and removed modifyCss transformer

* Create silly-kiwis-rest.md

* Formatting in changeset
  • Loading branch information
hooloovooo committed Dec 7, 2020
1 parent 040f453 commit 87a33d2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 115 deletions.
6 changes: 6 additions & 0 deletions .changeset/silly-kiwis-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@backstage/plugin-techdocs': minor
---

Removed modifyCss transformer and moved the css to injectCss transformer
Fixed issue where some internal doc links would cause a reload of the page
15 changes: 5 additions & 10 deletions plugins/techdocs/src/reader/components/Reader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import transformer, {
addLinkClickListener,
removeMkdocsHeader,
simplifyMkdocsFooter,
modifyCss,
onCssReady,
sanitizeDOM,
injectCss,
Expand Down Expand Up @@ -71,15 +70,6 @@ export const Reader = ({ entityId, onReady }: Props) => {
path,
}),
rewriteDocLinks(),
modifyCss({
cssTransforms: {
'.md-main__inner': [{ 'margin-top': '0' }],
'.md-sidebar': [{ top: '0' }, { width: '20rem' }],
'.md-typeset': [{ 'font-size': '1rem' }],
'.md-nav': [{ 'font-size': '1rem' }],
'.md-grid': [{ 'max-width': '80vw' }],
},
}),
removeMkdocsHeader(),
simplifyMkdocsFooter(),
injectCss({
Expand All @@ -92,6 +82,11 @@ export const Reader = ({ entityId, onReady }: Props) => {
--md-code-fg-color: ${theme.palette.text.primary};
--md-code-bg-color: ${theme.palette.background.paper};
}
.md-main__inner { margin-top: 0; }
.md-sidebar { top: 0; width: 20rem; }
.md-typeset { font-size: 1rem; }
.md-nav { font-size: 1rem; }
.md-grid { max-width: 80vw; }
`,
}),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ export const addLinkClickListener = ({
return dom => {
Array.from(dom.getElementsByTagName('a')).forEach(elem => {
elem.addEventListener('click', (e: MouseEvent) => {
const target = e.target as HTMLAnchorElement;
const href = target?.getAttribute('href');
const target = elem as HTMLAnchorElement;
const href = target.getAttribute('href');

if (!href) return;
if (href.startsWith(baseUrl)) {
e.preventDefault();
onClick(e, target.getAttribute('href')!);
onClick(e, href);
}
});
});
Expand Down
1 change: 0 additions & 1 deletion plugins/techdocs/src/reader/transformers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export * from './rewriteDocLinks';
export * from './addLinkClickListener';
export * from './removeMkdocsHeader';
export * from './simplifyMkdocsFooter';
export * from './modifyCss';
export * from './onCssReady';
export * from './sanitizeDOM';
export * from './injectCss';
Expand Down
58 changes: 0 additions & 58 deletions plugins/techdocs/src/reader/transformers/modifyCss.test.tsx

This file was deleted.

43 changes: 0 additions & 43 deletions plugins/techdocs/src/reader/transformers/modifyCss.ts

This file was deleted.

0 comments on commit 87a33d2

Please sign in to comment.