diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-06 18:10:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-06 18:10:04 +0300 |
commit | f3b1e07903a7f509b11ad7cf188fac46d98f77f6 (patch) | |
tree | a6fa5e65d83d94334387952f1f526ed438604408 /app/assets/javascripts/static_site_editor | |
parent | ba174c982f40d71a87fd511b091753807174f7e7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/static_site_editor')
-rw-r--r-- | app/assets/javascripts/static_site_editor/services/load_source_content.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/assets/javascripts/static_site_editor/services/load_source_content.js b/app/assets/javascripts/static_site_editor/services/load_source_content.js new file mode 100644 index 00000000000..1af93a8a2bc --- /dev/null +++ b/app/assets/javascripts/static_site_editor/services/load_source_content.js @@ -0,0 +1,15 @@ +import Api from '~/api'; + +const extractTitle = content => { + const matches = content.match(/title: (.+)\n/i); + + return matches ? Array.from(matches)[1] : ''; +}; + +const loadSourceContent = ({ projectId, sourcePath }) => + Api.getRawFile(projectId, sourcePath).then(({ data }) => ({ + title: extractTitle(data), + content: data, + })); + +export default loadSourceContent; |