Skip to content

Commit

Permalink
build: fix missing base_path (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaakaa authored May 19, 2024
1 parent bb5c4b1 commit 653c93f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- run: |
npm ci
npm run setup-repository --repository=${{ github.repository }} --pages_baseurl=${{ steps.configure-pages.outputs.base_url }}
npm run setup-repository --repository=${{ github.repository }} --pages_basepath=${{ steps.configure-pages.outputs.base_path }} --pages_baseurl=${{ steps.configure-pages.outputs.base_url }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dev": "slidev --open --remote 0.0.0.0",
"export": "slidev export --output dist/${npm_config_slide}.pdf --format pdf ${npm_config_slide}/slides.md",
"export:dark": "slidev export --dark --output dist/${npm_config_slide}-dark.pdf --format pdf ${npm_config_slide}/slides.md",
"setup-repository": "ts-node scripts/setup-repository.ts ${npm_config_repository} ${npm_config_pages_baseurl}"
"setup-repository": "ts-node scripts/setup-repository.ts ${npm_config_repository} ${npm_config_pages_basepath} ${npm_config_pages_baseurl}"
},
"dependencies": {
"@slidev/cli": "^0.49.0",
Expand Down
9 changes: 5 additions & 4 deletions scripts/setup-repository.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import fs from 'fs';

// ts-node scripts/setup-repository.ts [github.repository] [pages.base_url]
// ts-node scripts/setup-repository.ts [github.repository] [pages.base_path] [pages.base_url]
const args = process.argv.slice(2);
const repository = args[0] || 'kaakaa/slidev-resources-template';
const baseUrl = args[1] || '/slidev-resources-template';
const basePath = args[1] || '/slidev-resources-template';
const baseUrl = args[2] || 'https://kaakaa.github.cio/slidev-resources-template';

const values: { [key: string]: string } = {
'github.repository': repository,
Expand All @@ -17,9 +18,9 @@ const filesToRemove = [
'assets/'
];

/* replace pages.baseUrl in package.json*/
/* replace pages.basePath in package.json*/
let pkgjsonFile = fs.readFileSync('package.json', 'utf8');
pkgjsonFile = pkgjsonFile.replace( /--base \/slidev-resources-template/g, `--baes ${baseUrl}`);
pkgjsonFile = pkgjsonFile.replace( /--base \/slidev-resources-template/g, `--baes ${basePath}`);
fs.writeFileSync('package.json', pkgjsonFile, 'utf-8');


Expand Down

0 comments on commit 653c93f

Please sign in to comment.