Skip to content

Commit

Permalink
fix: revert language logic and introduce meta lang
Browse files Browse the repository at this point in the history
  • Loading branch information
SethFalco committed Dec 4, 2023
1 parent d5e0f1d commit a36784b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 46 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ resume export --theme @jsonresume/jsonresume-theme-class your-name.pdf

### Notes

* This theme expects languages in your résumé to be defined with language codes (i.e. `en`), not language names (i.e. `English`).
* If languages are specified, ensure the first language is the language your résumé is written in, so that the document language is set correctly.
* It's recommended to declare the `meta.language` property in your JSON Resume for accessibility. This is the [BCP47 tag](https://developer.mozilla.org/docs/Web/HTML/Global_attributes/lang#language_tag_syntax) for the language your your résumé is written in. For example, `en` for English.

## Features

Expand Down
13 changes: 0 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,6 @@ function render(resume) {
}
}

const primaryLanguage = resume.languages && resume.languages[0].language;

if (primaryLanguage) {
Handlebars.registerHelper("lang", (body) => {
const languageNames = new Intl.DisplayNames([primaryLanguage], {
type: 'language',

});

return languageNames.of(body);
});
}

const html = Handlebars.compile(template)({
css,
resume
Expand Down
60 changes: 31 additions & 29 deletions resume.handlebars
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
<!DOCTYPE html>
{{#if resume.languages.0.language}}
<html lang="{{resume.languages.0.language}}">
{{#if resume.meta.language}}
<html lang="{{resume.meta.language}}">
{{else}}
<html>
{{/if}}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary">
{{#if resume.basics.name}}
<title>{{resume.basics.name}} - CV</title>
<meta property="og:site_name" content="{{resume.basics.name}}">
{{else}}
<title>CV</title>
{{/if}}

{{#resume.basics}}
<title>{{name}} - CV</title>
<meta name="description" content="{{summary}}">
{{#if resume.basics.summary}}
<meta name="description" content="{{resume.basics.summary}}">
<meta property="og:description" content="{{resume.basics.summary}}">
{{/if}}

<meta property="og:site_name" content="{{name}}">
<meta property="og:title" content="{{label}}">
<meta property="og:description" content="{{summary}}">
{{#if resume.basics.label}}
<meta property="og:title" content="{{resume.basics.label}}">
{{/if}}

{{#if image}}
<link rel="icon" href="{{image}}">
<meta property="og:image" content="{{image}}">
<meta property="og:image:alt" content="Avatar of {{name}}.">
{{/if}}
{{/resume.basics}}
{{#if resume.basics.image}}
<meta property="og:image" content="{{resume.basics.image}}">
<link rel="icon" href="{{resume.basics.image}}">
{{#if resume.basics.name}}
<meta property="og:image:alt" content="Avatar of {{resume.basics.name}}.">
{{/if}}
{{/if}}

{{#resume.custom}}
{{#if xTwitterHandle}}
<meta name="twitter:site" content="{{xTwitterHandle}}">
{{/if}}
{{/resume.custom}}
{{#if resume.custom.xTwitterHandle}}
<meta name="twitter:site" content="{{resume.custom.xTwitterHandle}}">
{{/if}}

<style>
{{{css}}}
</style>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="twitter:card" content="summary">
<meta property="og:type" content="website">

<style>{{{css}}}</style>
</head>
<body>

Expand Down Expand Up @@ -313,9 +317,7 @@
{{#each resume.languages}}
<div class="item">
{{#if language}}
<div>
{{lang language}}
</div>
<div>{{language}}</div>
{{/if}}
{{#if fluency}}
<div class="level">
Expand Down
7 changes: 5 additions & 2 deletions test/fixture.resume.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"meta": {
"language": "en"
},
"basics": {
"name": "Seth Falco",
"label": "Open-Sourcerer 🧙‍♂️",
Expand Down Expand Up @@ -76,11 +79,11 @@
],
"languages": [
{
"language": "en",
"language": "English",
"fluency": "Native"
},
{
"language": "fr",
"language": "French",
"fluency": "Elementary"
}
]
Expand Down

0 comments on commit a36784b

Please sign in to comment.