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

fix: links to check tools #371

Merged
merged 6 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
HUGO_VERSION=0.83.1
BASE_URL=https://hugothemeiris.peaceiris.app
16 changes: 7 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,45 @@ bumphugo:

.PHONY: build
build:
$(eval opt := --minify --baseURL $(BASE_URL) --cleanDestinationDir)
$(eval opt := --minify --cleanDestinationDir)
$(DOCKER_COMPOSE) run --rm --entrypoint=hugo hugo $(opt)

.PHONY: npm-build
npm-build:
cd ./exampleSite && \
hugo --minify --baseURL $(BASE_URL) --cleanDestinationDir
hugo --minify --cleanDestinationDir

.PHONY: test
test:
$(eval opt := --minify --baseURL $(BASE_URL) \
$(eval opt := --minify \
--renderToMemory --i18n-warnings --path-warnings --debug)
$(DOCKER_COMPOSE) run --rm --entrypoint=hugo hugo $(opt)

.PHONY: npm-test
npm-test:
cd ./exampleSite && \
hugo --minify --baseURL $(BASE_URL) \
hugo --minify \
--renderToMemory --i18n-warnings --path-warnings --debug

.PHONY: metrics
metrics:
$(eval opt := --minify --baseURL $(BASE_URL) \
$(eval opt := --minify \
--renderToMemory --i18n-warnings --path-warnings --debug \
--templateMetrics --templateMetricsHints)
$(DOCKER_COMPOSE) run --rm --entrypoint=hugo hugo $(opt)

.PHONY: cibuild
cibuild:
cd ./exampleSite && \
hugo --minify \
--baseURL '/' \
--cleanDestinationDir \
hugo --minify --cleanDestinationDir \
--environment "staging" \
--i18n-warnings --path-warnings --debug \
--templateMetrics --templateMetricsHints

.PHONY: cibuild-prod
cibuild-prod:
cd ./exampleSite && \
hugo --minify --cleanDestinationDir \
--baseURL ${BASE_URL} \
--i18n-warnings --path-warnings && \
wget -O ./public/report.html ${BASE_URL}/report.html || true

Expand Down
2 changes: 1 addition & 1 deletion exampleSite/config/_default/config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
baseURL: "https://example.com"
baseURL: "https://hugothemeiris.peaceiris.app"

module:
imports:
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/config/_default/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ icon:
x180: /favicon/apple-icon-180x180.jpg
mstile: /favicon/ms-icon-150x150.jpg

# disableBreadcrumbNavigation: true
disableBreadcrumbNavigation: false
3 changes: 1 addition & 2 deletions exampleSite/config/development/params.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Params for development (server mode)
hugoenv: development
stagingURL: "https://hugothemeiris.peaceiris.app"
productionBaseURL: "https://hugothemeiris.peaceiris.app"
1 change: 0 additions & 1 deletion exampleSite/config/production/params.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# Params for production (build mode)
hugoenv: production
2 changes: 2 additions & 0 deletions exampleSite/config/staging/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Config for production
baseURL: "/"
1 change: 1 addition & 0 deletions exampleSite/config/staging/params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Params for production (build mode)
4 changes: 1 addition & 3 deletions layouts/_default/_markup/render-heading.html
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{{ if and (ne .Level "1") (ne .Level "2") }}
<h{{ .Level }} id="{{ .Anchor | safeURL }}" class="title is-5">{{ .Text | safeHTML }}</h{{ .Level }}>
{{ end }}
<h{{ .Level }} id="{{ .Anchor | safeURL }}" class="title is-{{ add .Level 1 }}">{{ .Text | safeHTML }}</h{{ .Level }}>
88 changes: 34 additions & 54 deletions layouts/partials/check-tools.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
{{ if ne $.Site.Params.hugoenv "production" }}
{{ $targetURL := $.Permalink }}
{{ if $.Site.IsServer }}
{{ $targetRelURL := .Page.Permalink | relURL }}
{{ $targetURL = delimit (slice $.Site.Params.stagingURL $targetRelURL) "" }}
{{ end }}

<div class="dropdown" id="checkTools">
<div class="dropdown-trigger">
<button class="button is-warning" aria-haspopup="true" aria-controls="dropdown-menu" onclick="toggleDropdownCheckTools();">
Expand All @@ -13,64 +6,51 @@
</div>
<div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content">
<a
href="https://developers.google.com/speed/pagespeed/insights/?url={{ $targetURL }}"
target="_blank"
rel="noopener noreferrer"
class="dropdown-item normal-link"
>Page Speed Insights</a
>
<a
href="https://search.google.com/test/rich-results?url={{ $targetURL }}"
target="_blank"
rel="noopener noreferrer"
class="dropdown-item normal-link"
>Rich result</a
>
<a
href="https://validator.w3.org/nu/?doc={{ $targetURL }}"
target="_blank"
rel="noopener noreferrer"
class="dropdown-item normal-link"
>Markup</a
>
<a
href="https://material.io/tools/resizer/#url={{ $targetURL }}"
target="_blank"
rel="noopener noreferrer"
class="dropdown-item normal-link"
>RESIZER</a
>
<a
href="https://search.google.com/test/mobile-friendly?url={{ $targetURL }}"
target="_blank"
rel="noopener noreferrer"
class="dropdown-item normal-link"
>Mobile</a
>
<a
href="https://developers.facebook.com/tools/debug/sharing/?q={{ $targetURL }}"
target="_blank"
rel="noopener noreferrer"
class="dropdown-item normal-link"
>Facebook</a
>
<button class="button dropdown-item" onclick="openCheckToolPage('pagespeedInsights');">
<span>Page Speed Insights</span>
</button>
<button class="button dropdown-item" onclick="openCheckToolPage('richResults');">
<span>Rich Result</span>
</button>
<button class="button dropdown-item" onclick="openCheckToolPage('mobileFriendly');">
<span>Mobile Friendly</span>
</button>
<button class="button dropdown-item" onclick="openCheckToolPage('w3Validator');">
<span>Validate Markup</span>
</button>
<button class="button dropdown-item" onclick="openCheckToolPage('facebook');">
<span>Facebook Sharing Debugger</span>
</button>
<a
href="https://cards-dev.twitter.com/validator"
target="_blank"
rel="noopener noreferrer"
class="dropdown-item normal-link"
>Twitter</a
class="button dropdown-item"
>Twitter Card Validator</a
>
</div>
</div>
</div>

<script>
function toggleDropdownCheckTools() {
var obj = document.getElementById("checkTools");
const obj = document.getElementById("checkTools");
obj.classList.toggle("is-active");
}
</script>

{{ end }}
function openCheckToolPage(toolName) {
const toolsTable = {
pagespeedInsights: 'https://developers.google.com/speed/pagespeed/insights/?url=',
richResults: 'https://search.google.com/test/rich-results?url=',
mobileFriendly: 'https://search.google.com/test/mobile-friendly?url=',
w3Validator: 'https://validator.w3.org/nu/?doc=',
facebook: 'https://developers.facebook.com/tools/debug/?q=',
}
{{ if $.Site.IsServer }}
const toolURL = toolsTable[toolName] + '{{ $.Site.Params.productionBaseURL | safeURL }}{{ .RelPermalink }}';
{{ else }}
const toolURL = toolsTable[toolName] + window.location.href;
{{ end }}
window.open(toolURL, '_blank', 'noreferrer');
}
</script>
2 changes: 1 addition & 1 deletion layouts/partials/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{{ $hasH2 := findRE "</h2>" $content }}
{{ if $hasH2 }}
{{ $content = $content | replaceRE "<h2 " "</section><section class=\"section\"><h2 class=\"title is-3\" " }}
{{ $content = $content | replaceRE "<h2 " "</section><section class=\"section\"><h2 " }}
{{ end }}

{{ $content = $content | replaceRE "<ul>\n<li>" "<div class=\"content\"><ul><li>" }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/keyboard-shortcut.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
{{ $secureJS := $js | resources.Fingerprint "sha512" }}
<script src="{{ $secureJS.Permalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script>
<script>
var keyboardShortcutHelpModal = document.getElementById("keyboard-shortcut-help-modal");
const keyboardShortcutHelpModal = document.getElementById("keyboard-shortcut-help-modal");

function toggleActive(obj) {
obj.classList.toggle("is-active");
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/lang-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</div>
<script>
function toggleDropdownActive() {
var obj = document.getElementById("langDrop");
const obj = document.getElementById("langDrop");
obj.classList.toggle("is-active");
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/mathjax.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script defer>
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/mermaid.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{ $secureJS := $js | resources.Fingerprint "sha512" }}
<script src="{{ $secureJS.Permalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script>
<script>
var config = {
const mermaidConfig = {
startOnLoad: true,
flowchart: {
useMaxWidth: true,
Expand All @@ -13,5 +13,5 @@
securityLevel: "strict",
};

mermaid.initialize(config);
mermaid.initialize(mermaidConfig);
</script>
8 changes: 4 additions & 4 deletions layouts/shortcodes/github-sponsors-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
{{ $sponsorID := .sponsor.login }}
{{ $sponsorURL := delimit (slice "https://github.com/" $sponsorID) "" | safeURL }}
<div class="column is-3-mobile is-2-tablet">
<a href="{{ $sponsorURL }}" rel="noopener noreferrer" target="_blank" class="normal-link">
<figure class="image is-64x64">
<figure class="image is-64x64">
<a href="{{ $sponsorURL }}" rel="noopener noreferrer" target="_blank" class="normal-link">
<img
class="is-rounded"
alt="{{ $sponsorID }} | GitHub"
src="{{ $sponsorURL }}.png"
decoding="async"
loading="lazy"
/>
</figure>
</a>
<figcaption>{{ print $sponsorID }}</figcaption>
</a>
</figure>
</div>
{{ end }}
</div>