Skip to content

Commit

Permalink
Add canonical meta tag
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Dec 2, 2024
1 parent fdc73d5 commit d5350b0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions code/go/site/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func staticAbsolutePath(path string) string {
return "https://data-star.dev/" + staticSys.HashName("static/"+path)
}

func canonicalUrl(uri string) string {
return "https://data-star.dev" + uri
}

func RunBlocking(port int, readyCh chan struct{}) toolbelt.CtxErrFunc {
return func(ctx context.Context) error {

Expand Down
2 changes: 1 addition & 1 deletion code/go/site/routes_bundler.templ
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

templ PageBundler(r *http.Request, manifest PluginManifest, store *BundlerStore) {
@Page("Bundler", "Bundle only the plugins you need to reduce the size of Datastar even further.") {
@Page("Bundler", "Bundle only the plugins you need to reduce the size of Datastar even further.", "/bundler") {
@header(r)
<div data-store={ templ.JSONString(store) } class="p-8 flex flex-col gap-4">
<div>
Expand Down
1 change: 1 addition & 0 deletions code/go/site/routes_home.templ
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ templ Home() {
@Page(
"Datastar - A real-time hypermedia framework",
"Datastar helps you build real-time web applications with the simplicity of server-side rendering and the power of a full-stack SPA framework.",
"/",
) {
<div class="flex flex-col w-full min-h-screen bg-base-200 md:bg-gradient-to-br md:items-center from-base-300 to-base-100">
<div class="flex flex-col items-stretch gap-7 p-4 md:pt-8 md:max-w-3xl max-w-none">
Expand Down
2 changes: 1 addition & 1 deletion code/go/site/routes_memes.templ
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package site
import "net/http"

templ PageMemes(r *http.Request, memes ...string) {
@Page("Hot fresh memes", "The most wasted of all days is one without laughter.") {
@Page("Hot fresh memes", "The most wasted of all days is one without laughter.", "/memes") {
@header(r)
<div class="flex flex-col gap-4 p-8">
<div class="text-4xl font-bold text-center">Memes</div>
Expand Down
9 changes: 5 additions & 4 deletions code/go/site/shared.templ
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ import (
"strings"
)

templ Page(title, description string) {
templ Page(title, description string, uri string) {
<!DOCTYPE html>
<html lang="en">
<head>
<title>{ title }</title>
<meta name="description" content={ description }/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link href={ staticPath("css/site.css") } rel="stylesheet" type="text/css"/>
<link rel="canonical" href={ canonicalUrl(uri) }/>
<link rel="stylesheet" href={ staticPath("css/site.css") } type="text/css"/>
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:[email protected]&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Orbitron:[email protected]&display=swap" rel="stylesheet"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Fira+Code:[email protected]&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Orbitron:[email protected]&display=swap"/>
<link rel="apple-touch-icon" sizes="180x180" href={ staticPath("favicon/apple-touch-icon.png") }/>
<link rel="icon" type="image/png" sizes="32x32" href={ staticPath("favicon/favicon-32x32.png") }/>
<link rel="icon" type="image/png" sizes="16x16" href={ staticPath("favicon/favicon-16x16.png") }/>
Expand Down Expand Up @@ -154,7 +155,7 @@ templ SidebarPage(
r *http.Request, sidebarGroups []*SidebarGroup, current *SidebarLink,
title, description, contents string,
) {
@Page(title, description) {
@Page(title, description, r.URL.String()) {
@highlightCSS
<div class="drawer">
<input id="sidebar-drawer" type="checkbox" class="drawer-toggle"/>
Expand Down
1 change: 1 addition & 0 deletions code/go/site/static/images/rocket.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d5350b0

Please sign in to comment.