Skip to content

Commit 9bf4c10

Browse files
committed
add meta.ejs template
1 parent 3a6216c commit 9bf4c10

File tree

6 files changed

+57
-1
lines changed

6 files changed

+57
-1
lines changed

index.html

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width,initial-scale=1" />
6+
<meta name="theme-color" content="#fff" />
7+
<%- include('src/templates/meta', meta) %>
8+
59
<title><%= fn.getCVTitle(cv) %></title>
610
<style>
711
/* Note: if you add additional styles to this class, you should remove them in `@media print` to ensure .cv-container remains styleless when printing */

src/editor/index.html

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<meta charset="UTF-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<%- include('src/templates/meta', editorMeta) %>
8+
79
<title>JSONCV Editor</title>
810
<link rel="shortcut icon" href="../favicon.png" type="image/png">
911
<link rel="stylesheet" href="../scss/editor/index.scss" />

src/index.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
65
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta name="theme-color" content="#fff" />
7+
<%- include('src/templates/meta', meta) %>
8+
79
<link rel="shortcut icon" href="favicon.png" type="image/png">
810
<title>JSONCV</title>
911
<link rel="stylesheet" href="./scss/home.scss" />

src/templates/meta.ejs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<meta name="description" content="<%= description %>">
2+
<meta property="og:title" content="<%= title %>">
3+
<meta property="og:description" content="<%= description %>">
4+
<meta property="og:type" content="website">
5+
<% if (locals.url) { %>
6+
<meta property="og:url" content="<%= url %>">
7+
<link rel="canonical" href="<%= url %>" />
8+
<% } %>
9+
<% if (locals.twitter) { %>
10+
<meta name="twitter:card" property="twitter:card" content="<%= twitter.card %>">
11+
<meta name="twitter:creator" property="twitter:creator" content="@<%= twitter.username %>">
12+
<meta name="twitter:title" property="twitter:title" content="<%= title %>">
13+
<meta name="twitter:description" property="twitter:description" content="<%= description %>">
14+
<% } %>

vite.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const data = require(dataFilename)
1313
const renderData = getRenderData(data)
1414
renderData.theme = process.env.THEME || 'reorx'
1515
renderData.isProduction = process.env.NODE_ENV === 'production'
16+
renderData.meta = {
17+
title: data.basics.name,
18+
description: data.basics.summary.replace('\n', ' '),
19+
}
1620

1721

1822
export default defineConfig({

vite.config.site.js

+30
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
11
import { resolve } from 'path';
22
import { defineConfig } from 'vite';
3+
import { ViteEjsPlugin } from 'vite-plugin-ejs';
34

45
import { TransformEjs } from './src/lib/vite-plugins';
56

67
const rootDir = resolve(__dirname, 'src')
8+
const renderData = {
9+
meta: {
10+
title: "jsoncv",
11+
description: "A toolkit for building your CV with JSON and creating stylish HTML/PDF files.",
12+
url: "https://jsoncv.reorx.com",
13+
twitter: {
14+
card: "summary",
15+
username: "novoreorx",
16+
}
17+
},
18+
editorMeta: {
19+
title: "jsoncv Editor",
20+
description: "The online editor of the jsoncv project.",
21+
url: "https://jsoncv.reorx.com/editor/",
22+
twitter: {
23+
card: "summary",
24+
username: "novoreorx",
25+
}
26+
}
27+
}
728

829
export default defineConfig({
930
root: 'src',
@@ -26,5 +47,14 @@ export default defineConfig({
2647
},
2748
plugins: [
2849
TransformEjs(),
50+
ViteEjsPlugin(
51+
renderData,
52+
{
53+
ejs: (viteConfig) => ({
54+
// ejs options goes here.
55+
views: [resolve(__dirname)],
56+
})
57+
}
58+
),
2959
],
3060
})

0 commit comments

Comments
 (0)