From 5bb4d1ab1a19c4ce5ef665349d29943a35dfa45b Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Tue, 6 Feb 2018 11:16:22 -0800 Subject: [PATCH] ensure readmes for lb4 have correct links This is a follow-up to https://github.com/strongloop/loopback.io/pull/588 --- _layouts/readme.html | 21 ++++++--- pages/en/lb4/Creating-decorators.md | 3 +- .../packages/metadata/README.md} | 0 update-v4-readmes.sh | 43 +++++++++++-------- 4 files changed, 42 insertions(+), 25 deletions(-) rename pages/en/lb4/readmes/{metadata.md => loopback-next/packages/metadata/README.md} (100%) diff --git a/_layouts/readme.html b/_layouts/readme.html index 103253d58..a02f4442c 100644 --- a/_layouts/readme.html +++ b/_layouts/readme.html @@ -7,21 +7,32 @@ {% if page.source %} {% if page.branch %} {% assign repo-branch = page.source | append: '/tree/' | append: page.branch %} - {% assign readme-file = page.source | append: '-' | append: page.branch %} + {% assign readme-file = page.source | append: '-' | append: page.branch | append '.md' %} {% else %} - {% assign repo-branch = page.source %} - {% assign readme-file = page.source %} + {% assign repo-branch = page.source %} + {% assign readme-file = page.source | append '.md' %} + {% endif %} + + {% assign readme-loc = page.file | default: 'README.md' %} + {% if page.file %} + {% if page.branch %} + {% assign readme-file = page.source | append: '-' | append: page.branch | append '/' | append page.file %} + {% assign repo-branch = page.source | append: '/tree/' | append: page.branch | append: page.file %} + {% else %} + {% assign readme-file = page.source | append '/' | append page.file %} + {% assign repo-branch = page.source | append: '/tree/' | append: 'master' | append: page.file %} + {% endif %} {% endif %} {% assign org = page.org | default: "strongloop" %} {{content}} - {% capture included-readme %}{% include_relative readmes/{{readme-file}}.md %}{% endcapture %} + {% capture included-readme %}{% include_relative readmes/{{readme-file}} %}{% endcapture %} {{ included-readme | markdownify }} {% else %}

ERROR: No source specified for README

diff --git a/pages/en/lb4/Creating-decorators.md b/pages/en/lb4/Creating-decorators.md index 7bf703e14..cd19c2c42 100644 --- a/pages/en/lb4/Creating-decorators.md +++ b/pages/en/lb4/Creating-decorators.md @@ -3,7 +3,8 @@ lang: en title: 'Creating decorators' keywords: LoopBack 4.0, LoopBack 4 layout: readme -source: metadata +source: loopback-next +file: packages/metadata/README.md tags: sidebar: lb4_sidebar permalink: /doc/en/lb4/Creating-decorators.html diff --git a/pages/en/lb4/readmes/metadata.md b/pages/en/lb4/readmes/loopback-next/packages/metadata/README.md similarity index 100% rename from pages/en/lb4/readmes/metadata.md rename to pages/en/lb4/readmes/loopback-next/packages/metadata/README.md diff --git a/update-v4-readmes.sh b/update-v4-readmes.sh index 0f1b6c847..c921caacd 100755 --- a/update-v4-readmes.sh +++ b/update-v4-readmes.sh @@ -1,38 +1,43 @@ #!/bin/bash -# The following is a 5 column list of org, repo, branch, package, and file. -# - If the branch is NOT specified, then the README for that project -# will be pulled from npmjs.org instead and will reflect the latest -# release. +# The following is a 5 column list of org, repo, branch, file, and module. +# - If the module is specified, the README for that project will be +# pulled from npmjs.org instead and will reflect the latest release. +# For scoped packages such as `@loopback/metadata`, the `/` needs to +# be encoded as `%2f`. For example `@loopback%2fmetadata`. # - If the branch IS specified, it will be used to fetch the README.md # from the given github repo. If that branch is NOT master, then the # branch name will be appended to the local readme file name. +# +# Examples: +# strongloop loopback-next master packages/metadata/README.md +# strongloop loopback-next master packages/metadata/README.md @loopback%2fmetadata +# (cat < $DEST else - # The loopback-example-database repo contains a separate branch for each - # actual example project, so we need to add the branch name to the readme - # name. - if [ "$branch" != "master" ]; then - DEST="pages/en/lb4/readmes/$package-$branch.md" - fi - echo "fetching $org/$repo/$branch/packages/$package from GitHub's raw content domain..." + echo "fetching $org/$repo/$branch/$file from GitHub's raw content domain..." curl -s $GHURL > $DEST fi done