Commit 9a321d39 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'feat/switch-repo-stats' into 'master'

feat: update stats (tags, version, stars) when switching repository

See merge request to-be-continuous/doc!115
parents 047cc2e4 73a84f34
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -27,3 +27,4 @@
/.docusaurus/
/node_modules/
/reports/
/docs/ref/angular.md
+2 −1
Original line number Diff line number Diff line
site_name: to be continuous
site_url: !ENV [SITE_URL, CI_PAGES_URL, 'https://to-be-continuous.gitlab.io/doc']
site_author: Pierre Smeyers
repo_url: !ENV [REPO_URL, CI_PROJECT_URL, 'https://gitlab.com/to-be-continuous']
repo_url: !ENV [REPO_URL, CI_PROJECT_URL, 'https://gitlab.com/to-be-continuous/doc']
repo_name: !ENV [REPO_NAME, CI_PROJECT_PATH, 'to-be-continuous/doc']
site_description: an opinionated framework for GitLab CI
site_dir: public
# edit_uri: doc/edit/master/docs/
+24 −21
Original line number Diff line number Diff line
{% if page.meta and page.meta.repo_url %}
<a href="{{ page.meta.repo_url }}" title="{{ lang.t('source') }}" class="md-source" data-md-component="source">
  <div class="md-source__icon md-icon">
{% set icon = config.theme.icon.repo or "fontawesome/brands/git-alt" %}
    {% include ".icons/" ~ icon ~ ".svg" %}
  </div>
  <div class="md-source__repository">
    {{ page.meta.repo_name }}
  </div>
{% set repo_url = page.meta.repo_url if (page.meta and page.meta.repo_url) else config.repo_url %}
{% set repo_name = page.meta.repo_name if (page.meta and page.meta.repo_name) else config.repo_name %}
<a href="{{ repo_url }}" title="{{ lang.t('source') }}" class="md-source" data-md-component="source">
  <div class="md-source__icon md-icon">{% include ".icons/" ~ icon ~ ".svg" %}</div>
  <div class="md-source__repository">{{ repo_name }}</div>
</a>
{% else %}
<a href="{{ config.repo_url }}" title="{{ lang.t('source') }}" class="md-source" data-md-component="source">
  <div class="md-source__icon md-icon">
    {% set icon = config.theme.icon.repo or "fontawesome/brands/git-alt" %}
    {% include ".icons/" ~ icon ~ ".svg" %}
  </div>
  <div class="md-source__repository">
    {{ config.repo_name }}
  </div>
</a>
{% endif %}
<script>
ss = sessionStorage
md_src_key = '/' + document.location.pathname.split('/')[1] + '/.__source'
if (ss['cur-repo'] != '{{ repo_name }}') {
  // maybe save current repo context to cache
  if (ss['cur-repo'] && ss[md_src_key]) {
    ss.setItem('/' + ss['cur-repo'] + '/.__source', ss[md_src_key])
  }
  // maybe restore new repo context from cache
  if (ss['/{{ repo_name }}/.__source']) {
    ss.setItem(md_src_key, ss['/{{ repo_name }}/.__source'])
  } else {
    ss.removeItem(md_src_key)
  }
  // set cur repo
  ss.setItem('cur-repo', '{{ repo_name }}')
}
</script>
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ function maybe_process_template() {
      curl -sS -H "$AUTH_HEADER" --output "$DOC_OUT/ref/$project_name.md" "$API_URL/projects/$project_id/repository/files/README.md/raw?ref=$project_default_branch"

      # add frontmatter
      sed -i "1i---\nrepo_name: $project_nice_name\ndescription: $template_desc\nrepo_url: $web_url\nimage_width: 256\nimage_height: 256\nimage_url: $avatar_url\n---\n" "$DOC_OUT/ref/$project_name.md"
      sed -i "1i---\nrepo_name: $project_path\ndescription: $template_desc\nrepo_url: $web_url\nimage_width: 256\nimage_height: 256\nimage_url: $avatar_url\n---\n" "$DOC_OUT/ref/$project_name.md"

      # write template card
      {