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

View File

@ -5,11 +5,17 @@ import {
getCVSavedTime, getCVSavedTime,
} from '../lib/store'; } from '../lib/store';
import { applyThemeTo } from '../themes'; import { applyThemeTo } from '../themes';
import { getCVTitle } from '../themes/data';
const themeName = 'default' const themeName = 'default'
const elCV = document.querySelector('.cv-container') 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() const savedTime = getCVSavedTime()
console.log('preview loaded', Date.now()) console.log('preview loaded', Date.now())

View File

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