Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

feat(stackblitz): start sb on index #373 #390

Merged
merged 1 commit into from
Feb 13, 2018
Merged
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
9 changes: 5 additions & 4 deletions src/app/shared/stackblitz/stackblitz-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Http} from '@angular/http';
import {ExampleData} from '@angular/material-examples';
import {VERSION} from '@angular/material';

const STACKBLITZ_URL = 'https://run.stackblitz.com/api/angular/v1/';
const STACKBLITZ_URL = 'https://run.stackblitz.com/api/angular/v1';

const COPYRIGHT =
`Copyright 2018 Google Inc. All Rights Reserved.
Expand Down Expand Up @@ -71,7 +71,8 @@ export class StackblitzWriter {
* called with submit().
*/
constructStackblitzForm(data: ExampleData): Promise<HTMLFormElement> {
let form = this._createFormElement();
const indexFile = `app%2F${data.indexFilename}.ts`;
const form = this._createFormElement(indexFile);

TAGS.forEach((tag, i) => this._appendFormInput(form, `tags[${i}]`, tag));
this._appendFormInput(form, 'private', 'true');
Expand All @@ -97,9 +98,9 @@ export class StackblitzWriter {
}

/** Constructs a new form element that will navigate to the stackblitz url. */
_createFormElement(): HTMLFormElement {
_createFormElement(indexFile: string): HTMLFormElement {
const form = document.createElement('form');
form.action = STACKBLITZ_URL;
form.action = `${STACKBLITZ_URL}?file=${indexFile}`;
form.method = 'post';
form.target = '_blank';
return form;
Expand Down