Skip to content

Commit

Permalink
build path correctly for github & server, close #9
Browse files Browse the repository at this point in the history
  • Loading branch information
TRMSC committed Nov 5, 2023
1 parent 364728c commit 44f0a41
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions docs/src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,13 @@ generateScene = () => {

// Get template
let templateName = document.getElementById('imagescene-template').value;
//let templatePath = '../templates/' + templateName + '.raw';
let templatePath = 'https://raw.githubusercontent.com/TRMSC/imagescene-generator/main/templates/' + templateName + '.raw';

// Build path
const baseUrl = new URL(window.location.href);
let relativePath = '../templates/' + templateName + '.raw';
let absolutePath = new URL(relativePath, baseUrl).href;
let templatePath = absolutePath.includes('github') ? absolutePath.replace('/blob/', '/raw/') : relativePath;
console.log('path is ' + templatePath);

// Fetch template content
let templateContent = '';
Expand Down

0 comments on commit 44f0a41

Please sign in to comment.