Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up content model #27

Merged
merged 65 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
4892e28
refactor(model,templating): Merge page, seo and t-default into t-page
peterschewe Jul 4, 2022
f53a387
build: upgrade contentful-migrations package
peterschewe Jul 4, 2022
f0a39db
chore(migrations): remove unused function params
peterschewe Jul 4, 2022
3b3cc68
refactor(model): remove m-section
peterschewe Jul 4, 2022
55d722f
chore: remove TODO comments
peterschewe Jul 4, 2022
0d7cb41
chore: remove obsolete styles of m-section
peterschewe Jul 4, 2022
3282f93
chore: remove TODO comment
peterschewe Jul 4, 2022
2afc413
fix(sonarlint): rename unused param and make intention explicit
peterschewe Jul 4, 2022
0a34289
refactor(migrations): add/update descriptions of content types
peterschewe Jul 4, 2022
965c178
refactor(migrations): change internal_name fields and make all required
peterschewe Jul 4, 2022
2730ba7
refactor(migrations): limit the allowed entries in m-columns
peterschewe Jul 4, 2022
abf24da
refactor: remove 'folder' from menuRootTypes in cssg presets
peterschewe Jul 4, 2022
6ac2e72
refactor: change to .Params.sys after content model refactoring
peterschewe Jul 4, 2022
d268ede
refactor(migrations): use withHelpers function
peterschewe Jul 4, 2022
237bdf1
docs: remove todos from Storybook introduction page
peterschewe Jul 5, 2022
5726789
refactor: remove t-default from Storybook
peterschewe Jul 5, 2022
560ae41
build: bump cssg packages to latest version
peterschewe Jul 5, 2022
2801cda
refactor: disable lazy load option for editors
peterschewe Jul 5, 2022
907c37c
feat: add editor layout and separate page settings
peterschewe Jul 6, 2022
9dc22b3
refactor: disable theming option for editors
peterschewe Jul 6, 2022
415209a
docs: change intro text in Storybook
peterschewe Jul 6, 2022
990c94f
refactor: align naming of headlines with ui/ux
peterschewe Jul 6, 2022
ecebefe
chore: remove superfluous comments
peterschewe Jul 6, 2022
466b930
chore: delete obsolete c-module-header partial
peterschewe Jul 10, 2022
878a93e
fix: use snake case var names
peterschewe Jul 10, 2022
ea96c3c
fix: use snake case var names
peterschewe Jul 10, 2022
cc89fc7
refactor: change column to array but limit it to one entry
peterschewe Jul 10, 2022
c84d602
refactor: remove defaultValue from disabled theme fields
peterschewe Jul 10, 2022
51a41dd
refactor: add subline and rename secondary headline to overline
peterschewe Jul 11, 2022
b4b89c8
refactor: define page type and components
peterschewe Jul 11, 2022
340eb6a
refactor: change order of overline and headline
peterschewe Jul 11, 2022
4c18ba2
fix(m-text): remove headings because template does not support them
peterschewe Jul 11, 2022
7a0081d
refactor: be backwards compatible with page content type
peterschewe Jul 11, 2022
44270d8
fix: use specific t-page instead of a glob
peterschewe Jul 11, 2022
1fd0523
refactor: use HUGO_ENV instead of HUGO_ENVIRONMENT
peterschewe Jul 14, 2022
a698595
Merge branch 'main' into feature/23-clean-up-content-model
Jul 15, 2022
91884af
fix(migrations): bump contentful-migrations package
Jul 16, 2022
a2603fc
lint
Jul 16, 2022
7e6d9af
Adds watch scripts to package.json
Jul 17, 2022
9c4387a
refactor: rename .modules to .content
peterschewe Jul 18, 2022
138ebdc
refactor: add d-seo content type
peterschewe Jul 18, 2022
620f67e
fix: add missing again
peterschewe Jul 18, 2022
4b045ea
fix: use correct share image url
peterschewe Jul 18, 2022
01652ce
chore: update comment block
peterschewe Jul 18, 2022
f5a1b06
refactor: remove the ability to change the logo via Contentful
peterschewe Jul 19, 2022
7bad785
feat: change the default_share_image and site_name via Contentful
peterschewe Jul 19, 2022
c6ec445
feat: change the default_share_image, site_name and global title via …
peterschewe Jul 19, 2022
06099b5
chore: remove whitespace from watch script
peterschewe Jul 19, 2022
f20106b
Merge branch 'feature/23-clean-up-content-model' of https://github.co…
peterschewe Jul 19, 2022
f0469c6
fix: remove debug output
peterschewe Jul 19, 2022
08ad849
refactor: Add clustering for label of menu field
peterschewe Jul 19, 2022
dff5870
refactor: Remove omitted theme option in templates
peterschewe Jul 19, 2022
e4bccb5
refactor: add default translations
peterschewe Jul 19, 2022
da85d49
style: add spacing and border to footer
peterschewe Jul 19, 2022
fe4b4cd
chore: change comment and remove empty lines
peterschewe Jul 19, 2022
a363bdd
refactor: rename m-editorial to m-hero
peterschewe Jul 19, 2022
ad8f24e
refactor: disable layout option for editor view
peterschewe Jul 20, 2022
3815bb0
chore: remove empty lines in items object
peterschewe Jul 20, 2022
7162320
refactor: add m-media as allowed module in t-page
peterschewe Jul 20, 2022
db58cb0
refactor: disable hero content in m-stage
peterschewe Jul 21, 2022
da19405
refactor: add menu identifier
peterschewe Jul 27, 2022
4a66cd1
refactor: remove explicit mod version
peterschewe Jul 27, 2022
a406297
build: reset package-lock
peterschewe Jul 27, 2022
cae9c55
fix: correct the font path
peterschewe Jul 28, 2022
db3abe2
refactor: Remove the check on page type
peterschewe Jul 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hugo-modules/core/layouts/storybook/single.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
{{- $combinations := partial "combinations" (dict "list" $templateParams) }}

{{ $params := merge site.Params (dict
"environment" (or (getenv "HUGO_ENVIRONMENT") hugo.Environment)
"environment" (or (getenv "HUGO_ENV") hugo.Environment)
) }}
{{- $js := resources.Get "js/main.js" | js.Build (dict
"format" "esm"
Expand Down
2 changes: 1 addition & 1 deletion hugo-modules/core/utils/get-category-name.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

{{- $result := "" -}}

{{- if hasPrefix $content_type "t-" -}}
{{- if (or (eq $content_type "page") (hasPrefix $content_type "t-")) -}}
{{- $result = "templates" -}}
{{- else if hasPrefix $content_type "m-" -}}
{{- $result = "modules" -}}
Expand Down
4 changes: 1 addition & 3 deletions hugo-modules/core/utils/get-data.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{/*
utils/get-data
Get data from contentful data types.
Get data from Contentful data types.

@example - Go Template
{{ partial "utils/get-data" (dict
Expand All @@ -23,8 +23,6 @@
{{ $result = or (index $contents (string $entry_id)) (index $contents (print (string $entry_id) "." $folder)) dict }}
{{ end }}
{{ end }}


{{ end }}

{{ return $result }}
2 changes: 1 addition & 1 deletion hugo-modules/core/utils/get-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{ $content_type := .content_type }}
{{ $page := dict }}
{{ if and $content_type $entry_id }}
{{ if (eq $content_type "page") }}
{{ if (or (eq $content_type "page") (hasPrefix $content_type "t-")) }}
{{ with index (where site.Pages "Params.sys.id" $entry_id) 0 }}
{{ $page = . }}
{{ end }}
Expand Down
10 changes: 3 additions & 7 deletions hugo-modules/core/utils/get-params.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@
{{ $content_type := .content_type }}
{{ $params := dict }}

{{ if (eq $content_type "page") }}
{{ $page := partial "utils/get-page" . }}
{{ with $page }}
{{ $params = .Params }}
{{ end }}
{{ $page := partial "utils/get-page" . }}
{{ with $page }}
{{ $params = .Params }}
{{ else }}
{{ $params = merge . (partial "utils/get-data" . )}}
{{ end }}



{{ return $params }}
2 changes: 1 addition & 1 deletion hugo-modules/core/utils/link.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{{ end }}

{{/* Page content type */}}
{{ else if eq .content_type "page" }}
{{ else if (or (eq .content_type "page") (hasPrefix .content_type "t-")) }}
{{ with partialCached "utils/get-page" . . }}
{{ $return = (dict
"href" (.Permalink | safeURL)
Expand Down
132 changes: 55 additions & 77 deletions hugo-modules/core/utils/seo/private/get-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

TODO:
- [ ] Improve type test on "events", `article` seems very opinated.
- [ ] Find a reasonable default image when `site.Params.default_image` is not set.
- [ ] Find a reasonable default image when `$settings.default_share_image` is not set.
- [ ] Twitter can sport "author" handle on top of the site's. Devise a test for author?
- [ ] Maybe consider another approach to set the twitter_card (summary, etc...)
- [ ] Not sure about image size. Following https://docs.imgix.com/best-practices/improving-seo-traffic, we have a
Expand All @@ -27,9 +27,7 @@

{{/* Adding the seo map to scratch which will recieve SEO key/value pairs. */}}
{{ $s := newScratch }}
{{ $s.Set "seo" dict }}


{{ $s.Set "seo" dict }}

{{ $seo_params := dict }}
{{ with .Params.seo }}
Expand All @@ -38,33 +36,27 @@
{{ $seo_params = . }}
{{ end }}
{{ end }}
{{ with .Params.content }}
{{ with partialCached "utils/get-params" . . }}
{{ $seo_params = merge . $seo_params }}
{{ end }}
{{ end }}

{{ $config := partialCached "utils/seo/private/get-config" "seo/private/get-config" }}
{{ $settings := partialCached "utils/get-settings" . }}

{{/* Dates
----------------------------- */}}

{{ if not .PublishDate.IsZero }}
{{ $s.SetInMap "seo" "published_time" (.PublishDate.Format "2006-01-02T15:04:05-07:00") }}
{{ else if not .Date.IsZero }}
{{ $s.SetInMap "seo" "published_time" (.Date.Format "2006-01-02T15:04:05-07:00") }}
{{ else }}
{{ if not .PublishDate.IsZero }}
{{ $s.SetInMap "seo" "published_time" (.PublishDate.Format "2006-01-02T15:04:05-07:00") }}
{{ else if not .Date.IsZero }}
{{ $s.SetInMap "seo" "published_time" (.Date.Format "2006-01-02T15:04:05-07:00") }}
{{ else }}
{{ with .Params.sys.created_at }}
{{ $s.SetInMap "seo" "published_time" (dateFormat "2006-01-02T15:04:05-07:00" .) }}
{{ $s.SetInMap "seo" "published_time" (dateFormat "2006-01-02T15:04:05-07:00" .) }}
{{ end }}
{{ end }}
{{ if not .Lastmod.IsZero }}
{{ $s.SetInMap "seo" "updated_time" (.Lastmod.Format "2006-01-02T15:04:05-07:00") }}
{{ end }}
{{ if not .Lastmod.IsZero }}
{{ $s.SetInMap "seo" "updated_time" (.Lastmod.Format "2006-01-02T15:04:05-07:00") }}
{{ else }}
{{ with .Params.sys.updated_at }}
{{ $s.SetInMap "seo" "updated_time" (dateFormat "2006-01-02T15:04:05-07:00" .) }}
{{ $s.SetInMap "seo" "updated_time" (dateFormat "2006-01-02T15:04:05-07:00" .) }}
{{ end }}
{{ end }}
{{ end }}

{{/* Description
----------------------------
Expand All @@ -84,7 +76,7 @@
{{/* 3. Summary */}}
{{ else if .Summary }}
{{ $description = .Summary }}
{{ else }}
{{ else }}
{{/* 4. site description */}}
{{ $description = site.Params.Description }}
{{ end }}
Expand All @@ -96,63 +88,61 @@
{{ end }}
{{ end }}


{{/* Title
----------------------------
We use the following logic
1. Every pages: `{.Title} | {site.Title}`
2. Homepage: , only {site.Title} */}}
{{ $title := .Title }}
1. Every pages: `Page title | Global site title`
2. Homepage: only `Global site title` */}}
{{ $title := "" }}
{{ with $seo_params.title }}
{{ $title = . }}
{{ end }}
{{ if not .IsHome }}
{{/* 1. `{.Title} | {.Site.Title}` */}}
{{ $s.SetInMap "seo" "title" (printf "%s | %s" $title site.Title) }}
{{/* 1. `Page title | Global site title` */}}
{{ $s.SetInMap "seo" "title" (printf "%s | %s" $title $settings.title) }}
{{ else }}
{{/* 2. `{.Site.Title}` */}}
{{ $s.SetInMap "seo" "title" site.Title }}
{{/* 2. `Global site title` */}}
{{ $s.SetInMap "seo" "title" $settings.title }}
{{ end }}


{{/* Site Name
---------------------------- */}}
{{ with $config.site_name }}
{{ $s.SetInMap "seo" "site_name" . }}
{{ with $settings.site_name }}
{{ $s.SetInMap "seo" "site_name" $settings.site_name }}
{{ else }}
{{ $s.SetInMap "seo" "site_name" site.Title }}
{{ $s.SetInMap "seo" "site_name" $settings.title }}
{{ end }}

{{/* Image
---------------------------- */}}
{{ $img := false }}

{{ with $config.default_image }}
{{ $img = . }}
{{ end }}
{{ with $settings.default_share_image }}
{{ $img = .url }}
{{ end }}

{{ with $seo_params.image }}
{{ $img = . }}
{{ with $seo_params.share_image }}
{{ $img = .url }}
{{ else }}
{{/* If no SEO IMAGE is set, we look for the .Params.images slice
and use the first one if it has an `image` key */}}
{{ with .Params.images }}
{{ with index . 0 }}
{{ with .Params.images }}
{{ with index . 0 }}
{{ if reflect.IsMap . }}
{{ with .image }}
{{ $img = . }}
{{ end }}
{{ with .image }}
{{ $img = .url }}
{{ end }}
{{ else }}
{{ $img = . }}
{{ $img = .url }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}

{{/* Finally if after all of the conditional above we are not able to find an image for the page,
we resolve to looking for the following: */}}
{{ if not $img }}
{{ $img_defaults := slice "/static/logo.jpg" "/static/logo.png" "/static/logo.svg" }}
{{ $img_defaults := slice "/static/logo.jpg" "/static/logo.png" "/static/logo.svg" }}
{{ range $path := $img_defaults }}
{{ if fileExists . }}
{{ $img = strings.TrimLeft "/static" $path }}
Expand All @@ -169,17 +159,16 @@
---------------------------- */}}
{{ with $img }}
{{/* Most of the time we should have an image */}}
{{ $s.SetInMap "seo" "twitter_card" "summary_large_image" }}
{{ $s.SetInMap "seo" "twitter_card" "summary_large_image" }}
{{ else }}
{{/* For edge cases without: */}}
{{ $s.SetInMap "seo" "twitter_card" "summary" }}
{{ $s.SetInMap "seo" "twitter_card" "summary" }}
{{ end }}


{{/* We check the site config sports a Social.twitter and use as handle */}}
{{ with .Site.Social.twitter }}
{{ $s.SetInMap "seo" "twitter_handle" (printf "@%s" .) }}
{{ end }}
{{ with .Site.Social.twitter }}
{{ $s.SetInMap "seo" "twitter_handle" (printf "@%s" .) }}
{{ end }}

{{/* We check if the page is not set as private */}}
{{ with $.Params.seo.private }}
Expand All @@ -191,28 +180,26 @@

{{/* Type
---------------------------- */}}
{{ $s.SetInMap "seo" "type" "website" }}
{{ $s.SetInMap "seo" "type" "website" }}

{{ if in (slice "blog" "news") .Type }}
{{ $s.SetInMap "seo" "type" "article" }}
{{ if in (slice "blog" "news") .Type }}
{{ $s.SetInMap "seo" "type" "article" }}
{{ else if in (slice "article") .Type }}
{{ $s.SetInMap "seo" "type" "event" }}
{{ end }}

{{ $s.SetInMap "seo" "type" "event" }}
{{ end }}

{{/* robots
{{/* Robots
---------------------------- */}}
{{ with $seo_params }}
{{ $no_index := .no_index | default false }}
{{ $no_follow := .no_follow | default false }}
{{ $s.SetInMap "seo" "no_index" $no_index }}
{{ $s.SetInMap "seo" "no_follow" $no_follow }}
{{ $s.SetInMap "seo" "no_index" $no_index }}
{{ $s.SetInMap "seo" "no_follow" $no_follow }}
{{ end -}}


{{/* Locale and translations
---------------------------- */}}
{{ $s.SetInMap "seo" "locale" .Lang }}
{{ $s.SetInMap "seo" "locale" .Lang }}

{{ $translations := slice }}
{{ if .IsTranslated }}
Expand All @@ -222,21 +209,15 @@
{{ $s.SetInMap "seo" "translations" $translations }}
{{ end }}


{{/* Canonical
---------------------------- */}}
{{ with $seo_params.canonical }}
{{ $s.SetInMap "seo" "canonical" (. | absURL) }}
{{ else }}
{{ $s.SetInMap "seo" "canonical" .Permalink }}
{{ end }}
{{ $s.SetInMap "seo" "canonical" .Permalink }}

{{ $seo := $s.Get "seo" }}
{{ if templates.Exists "partials/utils/seo/data.html" }}
{{ $seo = partial "utils/seo/data" (dict "seo" $seo "Page" $) }}
{{ end }}


{{ with $seo }}
{{ $s.SetInMap "jsonld" "@context" "https://schema.org" }}
{{ $s.SetInMap "jsonld" "@type" .type }}
Expand All @@ -254,7 +235,4 @@
{{ $seo = merge $seo (dict "jsonld" .) }}
{{ end }}




{{ return $seo }}
Loading