-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Create user card layout - Changed pdf.ts to file-generate.ts - added .has-skill for block skill
- Loading branch information
Showing
20 changed files
with
267 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
json | ||
files | ||
data.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import puppeteer, { Page } from "puppeteer"; | ||
import fs from "fs"; | ||
import { dirname } from "path"; | ||
import { fileURLToPath } from "url"; | ||
|
||
(async () => { | ||
const browser = await puppeteer.launch({ | ||
headless: true, | ||
}); | ||
const page = await browser.newPage(); | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
const fileToGenerate = process.argv[2]; | ||
let url = "http://localhost:8000/"; | ||
let fileName = "resume-default.pdf"; | ||
let fileType = "pdf"; | ||
let fileFolder = `${__dirname}/../data/files/`; | ||
|
||
if (process.argv[3]) | ||
fileType = process.argv[3]; | ||
|
||
if (!fs.existsSync(fileToGenerate)) { | ||
url += `${fileToGenerate}.html`; | ||
fileName = `${fileToGenerate}.${fileType}`; | ||
|
||
} | ||
|
||
const filePath = fileFolder + fileName; | ||
|
||
await getPage(page, __dirname, url); | ||
|
||
if (!fs.existsSync(fileFolder)) { | ||
fs.mkdirSync(fileFolder, { recursive: true }); | ||
} | ||
|
||
await generateFile(page, filePath, fileType); | ||
|
||
await browser.close(); | ||
|
||
console.log( | ||
`%s Your file is located at "${filePath}" ;) %s`, | ||
"\x1b[33m", | ||
"\x1b[0m" | ||
); | ||
|
||
})(); | ||
|
||
async function generateFile(page: Page, path: string, type: string): Promise<Buffer> { | ||
|
||
if (type === 'pdf') | ||
return await page.pdf({ | ||
format: "A4", | ||
// preferCSSPageSize: true, | ||
path: path, | ||
printBackground: true, | ||
margin: { | ||
top: "1cm", | ||
right: "1cm", | ||
bottom: "1cm", | ||
left: "1cm" | ||
}, | ||
}); | ||
|
||
// 1200x600 | ||
return await page.screenshot({ | ||
path: path, | ||
fullPage: true, | ||
}); | ||
} | ||
|
||
function getPage(page: Page, __dirname: string, url: string) { | ||
if (process.argv[2] && process.argv[2] === "--file=true") { | ||
const html = fs.readFileSync(`${__dirname}/../dist/index.html`, "utf8"); | ||
return page.setContent(html, { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
} | ||
|
||
return page.goto(url, {waitUntil: 'networkidle0'}); | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<script type="module" src="src/main.ts"></script> | ||
<link rel="stylesheet" href="src/style/user-card-default/main.scss"> | ||
<title>User Card</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.