Skip to content

Commit 6bbb284

Browse files
fix(endpoint-micropub): ignore empty name property in PTD. fixes #756
1 parent 9abcc7b commit 6bbb284

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

packages/endpoint-micropub/lib/post-type-discovery.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const getPostType = (postTypes, properties) => {
5959
// If post has `name` and content, it’s an article
6060
// This is a deviation from the Post Type Algorithm, which identifies a post
6161
// as a note if the content is prefixed with the `name` value.
62-
if (propertiesMap.has("name") && content) {
62+
if (properties.name && content) {
6363
return "article";
6464
}
6565

packages/endpoint-micropub/test/unit/post-type-discovery.js

+24
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ describe("endpoint-media/lib/post-type-discovery", () => {
1717
assert.equal(result, "note");
1818
});
1919

20+
it("Discovers note post type (with an empty title)", () => {
21+
const result = getPostType(postTypes, {
22+
type: "entry",
23+
name: "",
24+
content: "Note content",
25+
});
26+
27+
assert.equal(result, "note");
28+
});
29+
2030
it("Discovers article post type", () => {
2131
const result = getPostType(postTypes, {
2232
type: "entry",
@@ -88,6 +98,20 @@ describe("endpoint-media/lib/post-type-discovery", () => {
8898
assert.equal(result, "article");
8999
});
90100

101+
it("Discovers article post type (content begins with name)", () => {
102+
// Indiekit deviates from the Post Type Algorithm, which identifies a post
103+
// as a note if the content is prefixed with the `name` value.
104+
const result = getPostType(postTypes, {
105+
type: "entry",
106+
name: "Article about something",
107+
content: {
108+
text: "Article about something fishy.",
109+
},
110+
});
111+
112+
assert.equal(result, "article");
113+
});
114+
91115
it("Discovers photo post type", () => {
92116
const result = getPostType(postTypes, {
93117
type: "entry",

0 commit comments

Comments
 (0)