10000 feat(website): add raw json text to the manual installation option by favoyang · Pull Request #2522 · openupm/openupm · GitHub
[go: up one dir, main page]

Skip to content
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

feat(website): add raw json text to the manual installation option #2522

Merged
merged 1 commit into from
Oct 7, 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
1 change: 1 addition & 0 deletions docs/.vuepress/theme/components/PackageSetup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</div>
<PackageSetupViaPackageManager
:package-name="pkg.name"
:package-version="version"
:scopes="scopes"
/>
<div class="install-option last">
Expand Down
37 changes: 37 additions & 0 deletions docs/.vuepress/theme/components/PackageSetupViaPackageManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,34 @@
<CopyWrapper :copy-text="packageName"
><code>{{ packageName }}</code></CopyWrapper
>
into name
</li>
<li>
paste
<CopyWrapper :copy-text="packageVersion"
><code>{{ packageVersion }}</code></CopyWrapper
>
into version
</li>
<li>click <kbd>Add</kbd></li>
</ul>
<div class="divider text-center" data-content="OR"></div>
<p>
Alternatively, merge the snippet to
<a href="https://docs.unity3d.com/Manual/upm-manifestPrj.html"
>Packages/manifest.json</a
>
</p>
<div class="theme-default-content custom">
<!-- eslint-disable-next-line vue/no-v-html -->
<div class="language-json" v-html="manifest"></div>
</div>
</template>
</Modal>
</template>

<script>
import highlightjs from "highlight.js";
import Modal from "@theme/components/Modal.vue";
import CopyWrapper from "@theme/components/CopyWrapper.vue";
import util from "@root/docs/.vuepress/util";
Expand All @@ -46,12 +66,29 @@ export default {
components: { CopyWrapper, Modal },
props: {
packageName: { type: String, default: "" },
packageVersion: { type: String, default: "" },
scopes: {
type: Array,
default: () => [],
},
},
computed: {
manifest() {
const jsonData = {
scopedRegistries: [
{
name: this.registryName,
url: this.registryUrl,
scopes: this.scopes,
},
],
dependencies: {},
};
jsonData.dependencies[this.packageName] = this.packageVersion;
const jsonText = JSON.stringify(jsonData, null, 4);
const highlighted = highlightjs.highlight("json", jsonText).value;
return `<pre><code class="hljs json">${highlighted}</code></pre>`;
},
modalId() {
return "modal-manualinstallation";
},
Expand Down
0