+
Skip to content

adding HideAuthorName #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 1, 2021
Merged
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: 3 additions & 1 deletion wordpress-to-github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Controls how the service will place content in GitHub. This file belongs in your
}
],
"GeneralFilePath": "wordpress/general/general.json",
"ExcludeProperties": ["content", "_links"]
"ExcludeProperties": ["content", "_links"],
"HideAuthorName": false
}
}
```
Expand All @@ -55,6 +56,7 @@ Controls how the service will place content in GitHub. This file belongs in your
| **`ApiRequests.ExcludeProperties`** | A collection of property keys to remove from the output. |
| **`GeneralFilePath`** | The full path and filename for a `general.json` file that contains information about the whole site. |
| **`ExcludeProperties`** | Which WordPress properties should we suppress in output? |
| **`HideAuthorName`** | `true` to show user number for Author output instead of Name |

## Sample output

Expand Down
1 change: 1 addition & 0 deletions wordpress-to-github/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const fetchRetry = require("fetch-retry")(require("node-fetch/lib"), {
* @property {string} [PagePath]
* @property {string} [MediaPath]
* @property {string} [GeneralFilePath]
* @property {boolean} [HideAuthorName] True to hide author information.
* @property {EndpointRequestsConfigData[]} [ApiRequests]
*/

Expand Down
6 changes: 3 additions & 3 deletions wordpress-to-github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const SyncEndpoint = async (
//List of WP categories
const categorylist = await fetchDictionary(wordPressApiUrl, "categories");
const taglist = await fetchDictionary(wordPressApiUrl, "tags");
const userlist = await fetchDictionary(wordPressApiUrl, "users");
const userlist = endpointConfig.HideAuthorName ? null : await fetchDictionary(wordPressApiUrl, "users");

/** @type {WordpressMediaRow[] | null} */
const allMedia = endpointConfig.MediaPath
Expand Down Expand Up @@ -257,7 +257,7 @@ const SyncEndpoint = async (
/** @type {GithubOutputJson} */
const jsonData = {
...x,
author: userlist[x.author.toString()],
author: userlist ? userlist[x.author] : x.author,
wordpress_url: ensureStringStartsWith(
sourceEndpointConfig.WordPressSource.url,
x.source_url
Expand Down Expand Up @@ -376,7 +376,7 @@ const SyncEndpoint = async (
const wordPressRowToGitHubOutput = wpRow => {
const jsonData = {
...wpRow,
author: userlist[wpRow.author],
author: userlist ? userlist[wpRow.author] : wpRow.author,
wordpress_url: wpRow.link,
categories: mapLookup(wpRow, "categories", categorylist),
tags: mapLookup(wpRow, "tags", taglist)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Schema for a single wordpress-to-github endpoint",
"description": "Use this schema when building a wordpress-to-github.config for your Github branch.",
"$comment": "Version 2.0",
"$id": "wordpress-to-github_config_v2_0",
"$comment": "Version 2.1",
"$id": "wordpress-to-github_config_v2_1",
"type": "object",
"required": ["data"],
"additionalProperties": false,
Expand Down Expand Up @@ -109,6 +109,11 @@
"default": [],
"description": "Which properties should we suppress in output?",
"examples": [["content", "_links"]]
},
"HideAuthorName": {
"type": "boolean",
"description": "True to only display the numeric id for author.",
"default": false
}
}
}
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载