add title for cv html

This commit is contained in:
Reorx 2023-02-08 00:14:07 +08:00
parent 81f8198591
commit 2058f72ba2
3 changed files with 15 additions and 2 deletions

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CV</title>
<title><%= fn.getCVTitle(cv) %></title>
<style>
/* styles here should be removed in @media print */
body {

View File

@ -5,11 +5,17 @@ import {
getCVSavedTime,
} from '../lib/store';
import { applyThemeTo } from '../themes';
import { getCVTitle } from '../themes/data';
const themeName = 'default'
const elCV = document.querySelector('.cv-container')
applyThemeTo(themeName, elCV, getCVData())
const data = getCVData()
if (data) {
applyThemeTo(themeName, elCV, data)
// change document title
document.title = getCVTitle(data)
}
const savedTime = getCVSavedTime()
console.log('preview loaded', Date.now())

View File

@ -5,6 +5,7 @@ export function getRenderData(cvData) {
return {
cv: cvData,
fn: {
getCVTitle,
reformatDate,
getIconSVG,
noSchemaURL,
@ -14,6 +15,12 @@ export function getRenderData(cvData) {
/* fn */
export function getCVTitle(cv) {
let {name, version} = cv.meta
if (!name) name = cv.basics.name || 'JSONCV'
return `${name}${version ? ' ' + version : ''}`
}
function noSchemaURL(url) {
url = url.replace(/https?:\/\//, '')
if (url.endsWith('/')) {