Welcome to mirror list, hosted at ThFree Co, Russian Federation.

load_source_content.js « services « static_site_editor « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fcf69efafd8424fe4cd411c79498204859f96743 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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;