Skip to content

Commit

Permalink
feat(preset-hugo): always use content.text value
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Dec 29, 2020
1 parent 95d4724 commit 3243e8a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/preset-hugo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const HugoPreset = class {
postTemplate(properties) {
let content;
if (properties.content) {
content = properties.content.html || properties.content;
content = properties.content.text;
content = `${content}\n`;
} else {
content = '';
Expand Down
4 changes: 2 additions & 2 deletions packages/preset-hugo/tests/fixtures/properties.jf2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"slug": "cheese-sandwich",
"name": "Lunchtime",
"content": {
"html": "<p>I ate a <i>cheese</i> sandwich, which was nice.</p>",
"text": "I ate a cheese sandwich, which was nice."
"html": "<p>I ate a <em>cheese</em> sandwich, which was nice.</p>",
"text": "I ate a *cheese* sandwich, which was nice."
},
"summary": "What I ate.",
"category": ["foo", "bar"],
Expand Down
21 changes: 3 additions & 18 deletions packages/preset-hugo/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,6 @@ title: Lunchtime
`);
});

test('Renders post template with plaintext content', t => {
const hugo = new HugoPreset();
const result = hugo.postTemplate({
published: '2020-02-02',
name: 'Lunchtime',
content: 'I ate a cheese sandwich, which was nice.'
});
t.is(result, `---
date: 2020-02-02
title: Lunchtime
---
I ate a cheese sandwich, which was nice.
`);
});

test('Renders post template with JSON frontmatter', t => {
const hugo = new HugoPreset({frontmatterFormat: 'json'});
const result = hugo.postTemplate(t.context.properties);
Expand Down Expand Up @@ -91,7 +76,7 @@ test('Renders post template with JSON frontmatter', t => {
"syndication": "http://website.example/post/12345",
"mp-syndicate-to": "http://website.example"
}
<p>I ate a <i>cheese</i> sandwich, which was nice.</p>
I ate a *cheese* sandwich, which was nice.
`);
});

Expand Down Expand Up @@ -133,7 +118,7 @@ url = "http://website.example/photo.jpg"
[[videos]]
url = "http://website.example/video.mp4"
+++
<p>I ate a <i>cheese</i> sandwich, which was nice.</p>
I ate a *cheese* sandwich, which was nice.
`);
});

Expand Down Expand Up @@ -174,6 +159,6 @@ visibility: private
syndication: http://website.example/post/12345
mp-syndicate-to: http://website.example
---
<p>I ate a <i>cheese</i> sandwich, which was nice.</p>
I ate a *cheese* sandwich, which was nice.
`);
});

0 comments on commit 3243e8a

Please sign in to comment.