Skip to content

Commit ddcb69f

Browse files
Markdown output: render family page from front matter, serve at /<product>.md
Add layouts/index.md to render the family landing page's front matter (platforms, versions, install, capabilities, formats, resources) as real Markdown instead of dumping front matter. Publish the family .md at the bucket root as /<product>.md (deploy_product.yml + build-local.sh). Defensively strip a leading front-matter block in md/abs-content.txt for empty-body pages (CRLF-tolerant).
1 parent 047aa6c commit ddcb69f

5 files changed

Lines changed: 89 additions & 2 deletions

File tree

‎.github/workflows/deploy_product.yml‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,25 @@ jobs:
5555
chmod +x ./move_md_to_ugly_urls.sh
5656
./move_md_to_ugly_urls.sh public
5757
58+
- name: Publish family Markdown to bucket root as <product>.md
59+
# The product build's home is the family landing page; serve its .md at
60+
# /<product>.md (bucket root) instead of /<product>/index.md. Skipped for the
61+
# `home` build, whose root index.md is the site landing page.
62+
if: inputs.product_family != 'home'
63+
run: |
64+
BUCKET=${{ inputs.environment == 'production' && 'reference.groupdocs.com' || 'reference2.groupdocs.com' }}
65+
aws s3 cp public/index.md "s3://$BUCKET/${{ inputs.product_family }}.md" \
66+
--content-type "text/markdown; charset=utf-8" --region us-west-2
67+
env:
68+
AWS_ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY }}
69+
AWS_SECRET_ACCESS_KEY: ${{ secrets.SECRET_ACCESS }}
70+
71+
- name: Drop the prefixed family Markdown (served at /<product>.md instead)
72+
# Removing it locally makes `hugo deploy --maxDeletes` delete the old
73+
# /<product>/index.md from S3, so the family .md exists only at the root.
74+
if: inputs.product_family != 'home'
75+
run: rm -f public/index.md
76+
5877
- name: Deploy to S3
5978
run: hugo --configDir config/sites/groupdocs/${{ inputs.product_family }} --environment ${{ inputs.environment }} deploy --target "${{ inputs.environment == 'production' && 'Production' || 'Stage' }}" --maxDeletes ${{ inputs.max_deletes }}
6079
env:
@@ -65,7 +84,7 @@ jobs:
6584
uses: chetan/invalidate-cloudfront-action@v2
6685
env:
6786
DISTRIBUTION: ${{ inputs.environment == 'production' && secrets.AWS_DISTRIBUTION_PROD || secrets.AWS_DISTRIBUTION }}
68-
PATHS: ${{ inputs.invalidate_paths != '' && inputs.invalidate_paths || format('/{0}/*', inputs.product_family) }}
87+
PATHS: ${{ inputs.invalidate_paths != '' && inputs.invalidate_paths || format('/{0}/* /{0}.md', inputs.product_family) }}
6988
AWS_REGION: 'us-west-2'
7089
AWS_ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY }}
7190
AWS_SECRET_ACCESS_KEY: ${{ secrets.SECRET_ACCESS }}

‎README.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ consumption. Configured per product in `config/sites/groupdocs/<product>/_defaul
5656
The `.md` files are post-processed so they're clean and portable:
5757

5858
1. **No front matter, real Markdown** — `single.md` / `list.md` emit `.RawContent` (Hugo strips
59-
the YAML front matter), via the partial `layouts/partials/md/abs-content.txt`.
59+
the YAML front matter), via the partial `layouts/partials/md/abs-content.txt`. The product
60+
**family landing page** stores its content in front matter (platforms, capabilities, formats,
61+
resources) with an empty body, so `layouts/index.md` renders that data as Markdown instead
62+
(matching `family.html`). Its `.md` is published at the bucket root as **`/<product>.md`**
63+
(not `/<product>/index.md`) by `deploy_product.yml`.
6064
2. **Absolute links** — links are made absolute so they work no matter where the `.md` is served:
6165
- `abs-content.txt` (in-template) absolutizes **root-relative** links (`/path/` → `BASE/path.md`).
6266
- [`resolve_md_links.py`](resolve_md_links.py) (post-build) absolutizes **relative** links

‎build-local.sh‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ for p in "${PRODUCTS[@]}"; do
3131
-b "http://localhost:$PORT/$p/" -d "$PWD/$OUT/$p" --cleanDestinationDir --minify
3232
python resolve_md_links.py "$OUT/$p" --base-url "http://localhost:$PORT/$p" >/dev/null
3333
bash move_md_to_ugly_urls.sh "$OUT/$p" >/dev/null
34+
# Family page .md is served at /<product>.md (bucket root), not /<product>/index.md —
35+
# mirror that locally (production does this via deploy_product.yml).
36+
if [ -f "$OUT/$p/index.md" ]; then
37+
cp "$OUT/$p/index.md" "$OUT/$p.md"
38+
rm -f "$OUT/$p/index.md"
39+
fi
3440
done
3541

3642
echo

‎themes/docs/layouts/index.md‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{{- /* Home-page Markdown output.
2+
Product builds: the home IS the product family landing (layout: family) whose content
3+
lives entirely in front matter — render that data as real Markdown (mirrors family.html
4+
and products/ layouts/partials/md/layout-family.txt) so the .md is useful instead of a
5+
front-matter dump. Otherwise (site-root landing, layout: full-width) fall back to the
6+
generic body, identical to _default/list.md. */ -}}
7+
{{- if eq .Layout "family" -}}
8+
# {{ .Title }}
9+
{{ with (or .Params.lead .Description) }}
10+
{{ . }}
11+
{{ end }}
12+
{{- with .Params.platforms }}
13+
## Choose your platform
14+
{{ range . }}
15+
### {{ .name }}{{ with .version }} — v{{ . }}{{ end }}
16+
{{ with .install }}
17+
```
18+
{{ . }}
19+
```
20+
{{ end }}
21+
{{- $u := .ref | strings.TrimPrefix "/" | absURL | strings.TrimRight "/" -}}
22+
[Browse API reference]({{ $u }}.md)
23+
{{ end }}
24+
{{ end -}}
25+
{{- with .Params.capabilities }}
26+
## Key capabilities
27+
{{ range . }}
28+
- {{ . }}
29+
{{- end }}
30+
{{ end -}}
31+
{{- with .Params.formats }}
32+
## Supported formats
33+
{{ delimit . ", " }}
34+
{{ end -}}
35+
{{- with .Params.resources }}
36+
## Resources
37+
{{ range . }}
38+
- [{{ .name }}]({{ .url }})
39+
{{- end }}
40+
{{ end -}}
41+
{{- else -}}
42+
# {{ partial "utils/title" . }}
43+
{{ with .Description }}
44+
{{ . }}
45+
{{ end }}
46+
{{ partial "md/abs-content.txt" . }}
47+
{{ if and (not .Params.hideChildren) (.Pages) }}
48+
## Contents
49+
{{ range .Pages.ByWeight }}
50+
- [{{ partial "utils/title" . }}]({{ strings.TrimRight "/" .Permalink }}.md)
51+
{{- end }}
52+
{{ end }}
53+
{{- end -}}

‎themes/docs/layouts/partials/md/abs-content.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
links are left untouched. Single-language site, so BaseURL is sufficient. */ -}}
55
{{- $base := strings.TrimRight "/" .Site.BaseURL -}}
66
{{- $c := .RawContent -}}
7+
{{- /* 0. defensively strip a leading YAML front-matter block: for pages with an EMPTY body
8+
(e.g. an auto-generated namespace _index.md that is front matter only), Hugo's
9+
.RawContent can contain the front matter. The inner-line guard ([A-Za-z]) avoids
10+
matching a leading `---` horizontal rule (which is followed by a blank line). */ -}}
11+
{{- $c = replaceRE `(?s)\A---\r?\n[A-Za-z].*?\r?\n---\r?\n?` "" $c -}}
712
{{- /* 1. markdown PAGE links ](/path/) -> ](BASE/path.md) */ -}}
813
{{- $c = replaceRE `\]\((/[^)]*?)/\)` (printf "](%s${1}.md)" $base) $c -}}
914
{{- /* 2. remaining markdown root-relative links (assets) ](/...) -> ](BASE/...) */ -}}

0 commit comments

Comments
 (0)