share

package
v0.0.0-...-963cf5d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: GPL-3.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package share builds share buttons for a page: one plain link per service (or a button for "copy"), no third-party scripts, no cookies. Browsers with the Web Share API (phones) also get a "Share …" button for the system share sheet, shown by a few lines of script. Used by the blog (post pages) and the market (listing pages).

Index

Constants

This section is empty.

Variables

View Source
var Services = []string{"whatsapp", "telegram", "facebook", "x", "bluesky", "linkedin", "email", "copy"}

Services are the known service names, as written in Blog/Market { share: … }.

Functions

This section is empty.

Types

type Data

type Data struct {
	Links  []Link
	URL    string // absolute page URL, for copy and the system share sheet
	Title  string
	Label  string
	Native string
	Copied string
	Icon   template.HTML
	Class  string // CSS class prefix: <Class>, <Class>-btn, <Class>-<name> …
	Box    string // extra classes on the container, e.g. Bootstrap's "d-flex gap-2"
	Btn    string // extra classes on every button, e.g. Bootstrap's "btn btn-sm"
}

Data feeds the share buttons of a page.

func New

func New(names []string, pageURL, title, class string, t Texts) *Data

New builds the share buttons for the services in names (unknown names are skipped); nil when there are none. class is the CSS class prefix.

func (*Data) HTML

func (d *Data) HTML() (template.HTML, error)

HTML renders the buttons.

type Link struct {
	Name  string // service name, also the CSS class suffix: <Class>-<name>
	Label string // visible text and tooltip
	URL   string // empty for "copy"
	Icon  template.HTML
}

Link is one share button.

type Texts

type Texts struct {
	Label  string // heading, e.g. "Teilen"
	Native string // label of the system share button
	Email  string
	Copy   string
	Copied string // confirmation after "copy"
}

Texts are the labels of one language.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL