Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"useTabs": true,
"trailingComma": "none"
}
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,91 @@ Allowed values:

- A comma separated list with any of the following: `author`, `categories`, `coverImage`, `date`, `draft`, `excerpt`, `id`, `slug`, `tags`, `title`, `type`. You can rename a field by appending `:` and the alias to use. For example, `date:created` will rename `date` to `created`.

### Frontmatter meta

```
--frontmatter-meta=rank_math_seo_score:seo.score,title:seo.title,rank_math_contentai_score
```

Comma separated list of the WP post meta values to include in the frontmatter of Markdown files. Serialized PHP arrays get unserialized and converted to corresponding YAML structures. Dotted notation for nested frontmatter placement is supported with the example above reuslting in the following output:

```yaml
---
seo:
score: 90
title: SEO Title
rank_math_contentai_score: 85
---
```

### Append WP post meta to Content

```
--append-meta=staff_sidebar:sidebar
```

Extract listed WP post meta and append it to content using MDC component syntax.

e.g.
```
::sidebar
WP meta content from 'staff_sidebar' post meta key converted to markdown
::
```

### Specific content types

```
--post-types=post,page
```

Comma separated list of the content types to include in Markdown files. Leave empty to include all default content types.

Allowed values:

- A comma separated list: `post`, `page`, etc.

### Exclude specific content types

```
--exclude-post-types=nf_sub,et_pb_layout,acf-post-type,acf-field,acf-field-group,rm_content_editor,rank_math_schema
```

Comma separated list of the content types to exclude from Markdown files. Leave empty to include all default content types.

### Specific categories

```
--include-categories=news,resources
--exclude-categories=updates
```

Include or exclude content from specific categories based on those slugs.

### Strip shortcodes

```
--strip-shortcodes=true
```

Strip shortcodes from content converting the content therein into simple <div> tags.

Allowed values:

- `true` or `false`.

### Polylang translation sets support

```
--polylang=true
```

Include translations of posts in Markdown files. Translation sets will be produced with locale suffixes. E.g. `index.en.md` and `index.fr.md` for English- and French-language versions of the content.

Allowed values:

- `true` or `false`.

### Delay between image file requests?

```
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"chalk": "^5.4.1",
"commander": "^13.1.0",
"luxon": "^3.5.0",
"php-serialize": "^5.1.3",
"turndown": "^7.2.0",
"xml2js": "^0.6.2"
},
Expand Down
24 changes: 24 additions & 0 deletions src/frontmatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export function date(post) {
return post.date;
}

export function status(post) {
// status of the post, previously parsed and decoded
return post.data.childValue('status');
}

export function draft(post) {
// boolean representing the previously parsed draft status, only included when true
return post.isDraft ? true : undefined;
Expand All @@ -34,6 +39,11 @@ export function excerpt(post) {
return encoded ? encoded.replace(/[\r\n]+/gm, ' ') : undefined;
}

export function language(post) {
// language code, previously parsed and decoded
return post.polylang?.language || shared.config.polylangDefaultLanguage;
}

export function id(post) {
// previously parsed as a string, converted to integer here
return parseInt(post.id);
Expand All @@ -44,6 +54,20 @@ export function slug(post) {
return post.slug;
}

export function link(post) {
// previously parsed and decoded
if (post.link) {
try {
const url = new URL(post.link);
return url.pathname; // Extracts the path portion of the URL
} catch (error) {
// If post.link is not a valid URL, return it as is
return post.link;
}
}
return post.link;
}

export function tags(post) {
// array of decoded tag names (yes, they come from <category> nodes, not a typo)
const categories = post.data.children('category');
Expand Down
Loading