Skip to content

Commit

Permalink
Merge pull request #4 from gethinode/develop
Browse files Browse the repository at this point in the history
Initial release
  • Loading branch information
markdumay authored Sep 28, 2024
2 parents 7efbc28 + 684df3c commit 8ca8587
Show file tree
Hide file tree
Showing 18 changed files with 195 additions and 123 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Release
on:
workflow_dispatch:
# TODO: uncomment
# push:
# branches:
# - main
push:
branches:
- main

jobs:
release:
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: Test
on:
workflow_dispatch:
# TODO: uncomment
# push:
# tags:
# - v*
# branches: [ main ]
# pull_request:
# branches: [ main ]
push:
tags:
- v*
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
Expand Down
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Hinode Module - Template
# Hinode Module - HubSpot

<!-- Tagline -->
<p align="center">
<b>A template to define a Hugo module compatible with Hinode</b>
<b>A Hugo module to add Hubspot to your Hinode site (work in progress)</b>
<br />
</p>

Expand All @@ -14,41 +14,44 @@
<a href="https://gethinode.com" alt="Hinode theme">
<img src="https://img.shields.io/badge/theme-hinode-blue">
</a>
<a href="https://github.com/gethinode/mod-template/commits/main" alt="Last commit">
<img src="https://img.shields.io/github/last-commit/gethinode/mod-template.svg">
<a href="https://github.com/gethinode/mod-hubspot/commits/main" alt="Last commit">
<img src="https://img.shields.io/github/last-commit/gethinode/mod-hubspot.svg">
</a>
<a href="https://github.com/gethinode/mod-template/issues" alt="Issues">
<img src="https://img.shields.io/github/issues/gethinode/mod-template.svg">
<a href="https://github.com/gethinode/mod-hubspot/issues" alt="Issues">
<img src="https://img.shields.io/github/issues/gethinode/mod-hubspot.svg">
</a>
<a href="https://github.com/gethinode/mod-template/pulls" alt="Pulls">
<img src="https://img.shields.io/github/issues-pr-raw/gethinode/mod-template.svg">
<a href="https://github.com/gethinode/mod-hubspot/pulls" alt="Pulls">
<img src="https://img.shields.io/github/issues-pr-raw/gethinode/mod-hubspot.svg">
</a>
<a href="https://github.com/gethinode/mod-template/blob/main/LICENSE" alt="License">
<img src="https://img.shields.io/github/license/gethinode/mod-template">
<a href="https://github.com/gethinode/mod-hubspot/blob/main/LICENSE" alt="License">
<img src="https://img.shields.io/github/license/gethinode/mod-hubspot">
</a>
</p>

## About

![Logo](https://raw.githubusercontent.com/gethinode/hinode/main/static/img/logo.png)

Hinode is a clean blog theme for [Hugo][hugo], an open-source static site generator. Hinode is available as a [template][repository_template], and a [main theme][repository]. <!-- This repository maintains a Hugo module to add [module][module] to a Hinode site. --> Visit the Hinode documentation site for [installation instructions][hinode_docs].
Hinode is a clean blog theme for [Hugo][hugo], an open-source static site generator. Hinode is available as a [template][repository_template], and a [main theme][repository]. This repository maintains a Hugo module to embed [HubSpot][hubspot] forms within a Hinode site. Visit the Hinode documentation site for [installation instructions][hinode_docs].

## Contributing

This module uses [semantic-release][semantic-release] to automate the release of new versions. The package uses `husky` and `commitlint` to ensure commit messages adhere to the [Conventional Commits][conventionalcommits] specification. You can run `npx git-cz` from the terminal to help prepare the commit message.

<!-- ## Configuration
## Configuration

This module supports the following parameters (see the section `params.modules` in `config.toml`):

| Setting | Default | Description |
|---------------------------|---------|-------------| -->
|---------------------------|---------|-------------|
| region | na1 ||
| portalId | ||


<!-- MARKDOWN LINKS -->
[hugo]: https://gohugo.io
[hinode_docs]: https://gethinode.com
<!-- [module]: https://example.com -->
[hubspot]: https://hubspot.com
[repository]: https://github.com/gethinode/hinode.git
[repository_template]: https://github.com/gethinode/template.git
[conventionalcommits]: https://www.conventionalcommits.org
Expand Down
19 changes: 19 additions & 0 deletions assets/js/modules/hubspot/hubspot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// load the HubScript if at least one form is defined
if (document.querySelector('.form') !== null) {
const script = document.createElement("script");
script.setAttribute('src', 'https://js.hsforms.net/forms/embed/v2.js')
script.async = false
document.body.appendChild(script)

// create and embed each form within the designated div element
script.onload = () => {
document.querySelectorAll('.form').forEach(form => {
hbspt.forms.create({
region: form.getAttribute('data-region'),
portalId: form.getAttribute('data-portal-id'),
formId: form.getAttribute('data-form-id'),
target: `#${form.id}`
})
})
}
}
13 changes: 8 additions & 5 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
extended = true
min = "0.110.0"
max = ""
[[module.mounts]]
source = 'layouts'
target = 'layouts'
[[module.mounts]]
source = 'assets'
target = 'assets'
[[module.mounts]]
source = 'static'
target = 'static'
source = 'layouts'
target = 'layouts'
[[module.imports]]
path = "github.com/gethinode/mod-utils/v2"

[params.modules.hubspot]
integration = "core"
state = "async"
25 changes: 25 additions & 0 deletions data/structures/form.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
comment: >-
Creates an embedded form hosted by an external provider such as HubSpot.
arguments:
id:
type: string
position: 0
optional: false
comment: >-
The form's ID, which is used to retrieve the form definition.
portal:
type: int
optional: true
comment: >-
The portal ID of the HubSpot account where you created the form. This is
used to retrieve the form definition.
region:
type: select
optional: true
comment: >-
The region of the portal where the form was created. This is used to
retrieve the form definition.
options:
values:
- eu1
- na1
4 changes: 1 addition & 3 deletions exampleSite/content/_index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
title: Test site
description: Site to test module shortcode(s).
date: 2023-07-10
date: 2024-09-28
---

TODO: placeholder
4 changes: 1 addition & 3 deletions exampleSite/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module github.com/gethinode/mod-template/exampleSite
module github.com/gethinode/mod-hubspot/exampleSite

go 1.19

require github.com/gethinode/mod-template v0.0.0-20240912031743-7fd02bc201de // indirect
74 changes: 0 additions & 74 deletions exampleSite/go.sum

This file was deleted.

28 changes: 21 additions & 7 deletions exampleSite/hugo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
baseURL = 'http://example.org/'
languageCode = 'en-us'
title = 'Test site for mod-template'
title = 'Test site for mod-hubspot'

[module]
# Build and serve using local mod-template clone declared in the named Hugo workspace:
workspace = "mod-template.work"
# Build and serve using local mod-hubspot clone declared in the named Hugo workspace:
workspace = "mod-hubspot.work"
[[module.mounts]]
source = "content"
target = "content"
[[module.mounts]]
source = "data"
target = "data"
[[module.mounts]]
source = "layouts"
target = "layouts"
[[module.imports]]
path = "github.com/gethinode/mod-template"
path = "github.com/gethinode/mod-hubspot"
[[module.imports.mounts]]
source = "assets/js/modules/hubspot/hubspot.js"
target = "assets/js/hubspot.js"
[[module.imports.mounts]]
source = "dist"
target = "static"
source = "data"
target = "data"
[[module.imports.mounts]]
source = "layouts"
target = "layouts"
target = "layouts"
[[module.imports]]
path = "github.com/gethinode/mod-utils/v2"
10 changes: 10 additions & 0 deletions exampleSite/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,14 @@

{{ end }}
</body>
{{- $bundle := partial "utilities/bundle" (dict
"match" "{js/*.js,js/vendor/**.js}"
"filename" "js/main.bundle.js"
"basepath" "js/modules"
"all" true
"debugging" site.Params.debugging.showJS
) -}}

{{- $js := $bundle | resources.ExecuteAsTemplate "js/hubspot.js" . -}}
<script src="{{ $js.RelPermalink }}" async></script>
</html>
File renamed without changes.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module github.com/gethinode/mod-template
module github.com/gethinode/mod-hubspot

go 1.19

require github.com/gethinode/mod-utils/v2 v2.8.1 // indirect
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/gethinode/mod-utils/v2 v2.8.1 h1:u7sFbgJ5sBEMYC/GwcMRyjRAd5NxTjBnbld5b0V5n98=
github.com/gethinode/mod-utils/v2 v2.8.1/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
50 changes: 50 additions & 0 deletions layouts/partials/form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--
Copyright © 2024 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->

{{ $error := false }}

<!-- Initialize arguments -->
{{ $args := partial "utilities/InitArgs.html" (dict "structure" "form" "args" .) }}
{{ if $args.err }}
{{ partial "utilities/LogErr.html" (dict
"partial" "partials/form.html"
"msg" "Invalid arguments"
"details" $args.errmsg
"file" page.File
)}}
{{ $error = true }}
{{ end }}

<!-- Initialize local arguments -->
{{ $portal := $args.portal | default site.Params.modules.hubspot.portal }}
{{ $region := $args.region | default site.Params.modules.hubspot.region }}

{{ if not $region }}
{{ partial "utilities/LogErr.html" (dict
"partial" "partials/form.html"
"msg" "Form is missing region argument"
"file" page.File
)}}
{{ $error = true }}
{{ end }}

{{ if not $portal }}
{{ partial "utilities/LogErr.html" (dict
"partial" "partials/form.html"
"msg" "Form is missing portal argument"
"file" page.File
)}}
{{ $error = true }}
{{ end }}

<!-- Main code -->
{{ if not $error }}
<div class="form" id="form-{{ $args.id }}"
{{- with $args.id }} data-form-id="{{ . }}"{{ end -}}
{{- with $portal }} data-portal-id="{{ . }}"{{ end -}}
{{- with $region }} data-region="{{ . }}"{{ end -}}>
</div>
{{ end }}
Loading

0 comments on commit 8ca8587

Please sign in to comment.