Skip to content

Commit

Permalink
Fix Custom CSS URL Possible Double Slash (#60)
Browse files Browse the repository at this point in the history
* fix custom css url pathname

* fix formatting
  • Loading branch information
sinanbekar authored Feb 29, 2024
1 parent e92708e commit d47b4d1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/application/src/plugins/rise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -924,19 +924,26 @@ namespace Rise {
// https://github.com/jupyterlab-contrib/rise/issues/509
// Attempt to load rise.css
const curdir = PathExt.dirname(panel.sessionContext.path);
const riseCssUrl = new URL(
PathExt.join('files', curdir, 'rise.css'),
PageConfig.getBaseUrl()
);
document.head.insertAdjacentHTML(
'beforeend',
`<link rel="stylesheet" href="${PageConfig.getBaseUrl()}files/${curdir}/rise.css" id="rise-custom-css" />`
`<link rel="stylesheet" href="${riseCssUrl.href}" id="rise-custom-css" />`
);
const name = PathExt.basename(panel.sessionContext.path);
const dot_index = name.lastIndexOf('.');
const stem = dot_index === -1 ? name : name.substr(0, dot_index);
// associated css
const name_css = `${curdir}/${stem}.css`;
const nameCssUrl = new URL(
PathExt.join('files', curdir, `${stem}.css`),
PageConfig.getBaseUrl()
);
// Attempt to load css with the same path as notebook
document.head.insertAdjacentHTML(
'beforeend',
`<link rel="stylesheet" href="${PageConfig.getBaseUrl()}files/${name_css}" id="rise-notebook-css" />`
`<link rel="stylesheet" href="${nameCssUrl.href}" id="rise-notebook-css" />`
);

// Asynchronously import reveal
Expand Down

0 comments on commit d47b4d1

Please sign in to comment.