Skip to content

Commit

Permalink
Add single_version config to fix URLs.
Browse files Browse the repository at this point in the history
Fixes #14
  • Loading branch information
ericholscher committed Nov 21, 2022
1 parent c6550db commit f410764
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions preview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ These are all the parameters this action supports:
* `message-template` (_optional_): Text message to be injected by the action in the Pull Request description. It supports the following placeholders to be replaced:
* `{docs-pr-index-url}`: URL to the root of the documentation for the Pull Request preview.
* `platform` (_optional_): Read the Docs Community (`community`) or Read the Docs for Business (`business`). (default: `community`)
* `single_version` (_optional_): Set this to `'true'` if your project is single version, so we can link to the correct URL. (default: `false`)
4 changes: 4 additions & 0 deletions preview/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ inputs:
description: "Read the Docs Community or Read the Docs for Business (community or business)"
default: "community"
required: false
single_version:
description: "Site is a single verison project, so link to the top level."
default: 'false'
required: false

runs:
using: "composite"
Expand Down
7 changes: 6 additions & 1 deletion preview/scripts/edit-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ module.exports = async ({inputs, github, context}) => {
if (RTD_PLATFORM == "business") {
var RTD_DOMAIN = "com.readthedocs.build";
}
var RTD_URL = `https://${RTD_PROJECT_SLUG}--${PR_NUMBER}.${RTD_DOMAIN}/${RTD_PROJECT_LANGUAGE}/${PR_NUMBER}/`;
var RTD_DOMAIN = `https://${RTD_PROJECT_SLUG}--${PR_NUMBER}.${RTD_DOMAIN}/`;
if (RTD_SINGLE_VERSION == "true") {
RTD_URL = RTD_DOMAIN + `${RTD_PROJECT_LANGUAGE}/${PR_NUMBER}/`;
} else {
RTD_URL = RTD_DOMAIN;
}

var MESSAGE_SEPARATOR_START = `\r\n\r\n<!-- readthedocs-preview ${RTD_PROJECT_SLUG} start -->\r\n`;
var MESSAGE_SEPARATOR_END = `\r\n<!-- readthedocs-preview ${RTD_PROJECT_SLUG} end -->`;
Expand Down

0 comments on commit f410764

Please sign in to comment.