Serve fonts ourselves and write the privacy policy
Fonts: every Google font the editor offers (13 families, latin and latin-ext, 1.2 MB) now lives in public/fonts; the layout inlines @font-face rules only for the fonts in use, built from src/lib/font-faces.json. scripts/fonts-holen.py re-fetches them. The admin font preview loads the same files via /admin/fonts and /admin/api/font-faces. Checked: no request leaves larpaso.de on the start page, Impressum or Datenschutz, nor in the admin editor. nginx: access_log off, so visitor IPs are not stored. Caddy has no access log configured either. Privacy policy replaces the placeholder and describes only what the site actually does: controller (from the Impressum), hosting at netcup in Nuremberg (from the server IP), no access logs, HTTPS, mailto contact form and e-mail, self-hosted fonts and media, no cookies, data subject rights and the Lower Saxony supervisory authority. The closing note is no longer styled as a warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1b72de46ad
commit
2fa8dc6615
44 changed files with 396 additions and 39 deletions
|
|
@ -57,14 +57,21 @@
|
|||
const style = el('style', {}, [rules]);
|
||||
document.head.appendChild(style);
|
||||
|
||||
if (fonts.some((f) => f.name !== 'System UI (Systemschrift)' && f.name !== 'Georgia (Systemschrift)')) {
|
||||
const families = fonts
|
||||
.filter((f) => !f.name.includes('Systemschrift'))
|
||||
.map((f) => `family=${encodeURIComponent(f.name)}:wght@400;500;600;700`)
|
||||
.join('&');
|
||||
const link = el('link', { rel: 'stylesheet', href: `https://fonts.googleapis.com/css2?${families}&display=swap` });
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
// Font files come from our own server (/admin/fonts), not from Google.
|
||||
api('/admin/api/font-faces')
|
||||
.then((faces) => {
|
||||
const faceRules = Object.entries(faces)
|
||||
.flatMap(([name, list]) =>
|
||||
list.map(
|
||||
(face) =>
|
||||
`@font-face { font-family: '${name}'; font-weight: ${face.weight}; font-display: swap; ` +
|
||||
`src: url('/admin${face.file}') format('woff2'); unicode-range: ${face.unicodeRange}; }`,
|
||||
),
|
||||
)
|
||||
.join('\n');
|
||||
document.head.appendChild(el('style', {}, [faceRules]));
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
// --- Field renderers ---
|
||||
|
|
|
|||
|
|
@ -144,6 +144,13 @@ app.get('/admin/api/fonts', auth.requireAuth, (req, res) => {
|
|||
res.json(FONT_OPTIONS);
|
||||
});
|
||||
|
||||
// Font files are served from our own server (public/fonts), so the font
|
||||
// preview in the editor never contacts Google either.
|
||||
app.get('/admin/api/font-faces', auth.requireAuth, (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '..', 'src', 'lib', 'font-faces.json'));
|
||||
});
|
||||
app.use('/admin/fonts', auth.requireAuth, express.static(path.join(__dirname, '..', 'public', 'fonts')));
|
||||
|
||||
app.get('/admin/api/content', auth.requireAuth, (req, res) => {
|
||||
res.json(readContent());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -315,17 +315,41 @@
|
|||
"note": ""
|
||||
},
|
||||
"datenschutz": {
|
||||
"intro": "",
|
||||
"intro": "Wir freuen uns über Ihr Interesse an larpaso. Diese Erklärung beschreibt, welche personenbezogenen Daten beim Besuch dieser Website verarbeitet werden, zu welchem Zweck und welche Rechte Sie haben. Kurz gesagt: Wir setzen keine Cookies, keine Analyse- oder Werbedienste und keine eingebetteten Inhalte anderer Anbieter ein.",
|
||||
"sections": [
|
||||
{
|
||||
"heading": "Verantwortliche Stelle",
|
||||
"text": ""
|
||||
"heading": "1. Verantwortlicher",
|
||||
"text": "Verantwortlich für die Datenverarbeitung auf dieser Website ist:<br><br>Larpaso<br>Pascal Scholz<br>Weinkampswende 14<br>30539 Hannover<br><br>E-Mail: {email}"
|
||||
},
|
||||
{
|
||||
"heading": "Kontaktformular",
|
||||
"text": "Das Kontaktformular auf dieser Website öffnet beim Absenden Ihr E-Mail-Programm mit einem vorausgefüllten Entwurf. Ihre Angaben werden dabei direkt an {email} adressiert und nicht an einen Server dieser Website oder Dritte übertragen."
|
||||
"heading": "2. Hosting",
|
||||
"text": "Diese Website wird auf einem Server der netcup GmbH, Daimlerstraße 25, 76185 Karlsruhe, betrieben. Der Server steht in einem Rechenzentrum in Nürnberg (Deutschland).<br><br>Rechtsgrundlage ist unser berechtigtes Interesse an einer sicheren und zuverlässigen Bereitstellung der Website (Art. 6 Abs. 1 lit. f DSGVO)."
|
||||
},
|
||||
{
|
||||
"heading": "3. Aufruf der Website",
|
||||
"text": "Wenn Sie diese Website aufrufen, überträgt Ihr Browser technisch bedingt Ihre IP-Adresse, Datum und Uhrzeit der Anfrage, die aufgerufene Adresse sowie Angaben zu Browser und Betriebssystem. Diese Daten verarbeitet der Server ausschließlich, um Ihnen die Seite auszuliefern.<br><br>Wir speichern keine Zugriffsprotokolle. Nur wenn beim Ausliefern ein technischer Fehler auftritt, kann ein Fehlereintrag entstehen, der Ihre IP-Adresse enthält. Solche Einträge nutzen wir allein zur Fehlerbehebung und löschen sie, sobald sie dafür nicht mehr benötigt werden.<br><br>Rechtsgrundlage ist Art. 6 Abs. 1 lit. f DSGVO."
|
||||
},
|
||||
{
|
||||
"heading": "4. Verschlüsselung",
|
||||
"text": "Diese Website wird ausschließlich über eine verschlüsselte Verbindung (HTTPS) ausgeliefert. Sie erkennen das am Schloss-Symbol in der Adresszeile Ihres Browsers."
|
||||
},
|
||||
{
|
||||
"heading": "5. Kontaktformular und E-Mail",
|
||||
"text": "Das Kontaktformular auf dieser Website öffnet beim Absenden Ihr E-Mail-Programm mit einem vorausgefüllten Entwurf. Ihre Angaben werden dabei direkt an {email} adressiert und nicht an einen Server dieser Website oder Dritte übertragen. Erst wenn Sie die E-Mail in Ihrem Programm selbst abschicken, erhalten wir sie.<br><br>Wenn Sie uns eine E-Mail schreiben, verarbeiten wir Ihre Angaben (zum Beispiel Name, E-Mail-Adresse, Telefonnummer und Ihre Nachricht), um Ihre Anfrage zu beantworten. Ihre Nachricht wird dafür bei unserem E-Mail-Dienstleister gespeichert. Wir löschen sie, sobald die Anfrage abschließend bearbeitet ist, sofern keine gesetzlichen Aufbewahrungspflichten entgegenstehen.<br><br>Rechtsgrundlage ist Art. 6 Abs. 1 lit. b DSGVO, wenn Ihre Anfrage auf einen Vertrag zielt, und im Übrigen unser berechtigtes Interesse an der Beantwortung von Anfragen (Art. 6 Abs. 1 lit. f DSGVO)."
|
||||
},
|
||||
{
|
||||
"heading": "6. Schriftarten, Bilder und Videos",
|
||||
"text": "Alle Schriftarten, Bilder und Videos dieser Website liegen auf unserem eigenen Server. Beim Aufruf entsteht keine Verbindung zu Google oder anderen Drittanbietern."
|
||||
},
|
||||
{
|
||||
"heading": "7. Cookies",
|
||||
"text": "Diese Website setzt keine Cookies und speichert keine Daten in Ihrem Browser."
|
||||
},
|
||||
{
|
||||
"heading": "8. Ihre Rechte",
|
||||
"text": "Sie haben das Recht auf Auskunft über Ihre gespeicherten Daten (Art. 15 DSGVO), auf Berichtigung (Art. 16), auf Löschung (Art. 17), auf Einschränkung der Verarbeitung (Art. 18) und auf Datenübertragbarkeit (Art. 20). Soweit wir Daten auf Grundlage unseres berechtigten Interesses verarbeiten, können Sie dieser Verarbeitung widersprechen (Art. 21 DSGVO). Schreiben Sie uns dafür einfach an {email}.<br><br>Außerdem können Sie sich bei einer Datenschutz-Aufsichtsbehörde beschweren. Für uns zuständig ist die Landesbeauftragte für den Datenschutz Niedersachsen, Prinzenstraße 5, 30159 Hannover."
|
||||
}
|
||||
],
|
||||
"note": "Diese Datenschutzerklärung ist noch nicht vollständig und muss vor dem Livegang ergänzt bzw. rechtlich geprüft werden."
|
||||
"note": "Stand: Oktober 2026"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ server {
|
|||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# Keine Zugriffsprotokolle: Besucher-IPs werden nicht gespeichert
|
||||
# (so steht es auch in der Datenschutzerklaerung). Fehler weiter melden.
|
||||
access_log off;
|
||||
|
||||
# Saubere URLs + Fallback
|
||||
location / {
|
||||
try_files $uri $uri/ $uri.html /index.html;
|
||||
|
|
|
|||
93
public/fonts/OFL.txt
Normal file
93
public/fonts/OFL.txt
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright 2017 The Playfair Display Project Authors (https://github.com/clauseggers/Playfair-Display), with Reserved Font Name "Playfair Display"
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
4
public/fonts/README.txt
Normal file
4
public/fonts/README.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Alle Schriften in diesem Ordner stammen aus Google Fonts und stehen unter der
|
||||
SIL Open Font License 1.1 (Text in OFL.txt). Sie werden vom eigenen Server
|
||||
ausgeliefert, damit beim Seitenaufruf keine Verbindung zu Google entsteht.
|
||||
Neu laden: python scripts/fonts-holen.py (aus dem Repo-Wurzelordner).
|
||||
BIN
public/fonts/dm-serif-display/dm-serif-display-latin-1.woff2
Normal file
BIN
public/fonts/dm-serif-display/dm-serif-display-latin-1.woff2
Normal file
Binary file not shown.
BIN
public/fonts/dm-serif-display/dm-serif-display-latin-ext-0.woff2
Normal file
BIN
public/fonts/dm-serif-display/dm-serif-display-latin-ext-0.woff2
Normal file
Binary file not shown.
BIN
public/fonts/inter/inter-latin-1.woff2
Normal file
BIN
public/fonts/inter/inter-latin-1.woff2
Normal file
Binary file not shown.
BIN
public/fonts/inter/inter-latin-ext-0.woff2
Normal file
BIN
public/fonts/inter/inter-latin-ext-0.woff2
Normal file
Binary file not shown.
BIN
public/fonts/libre-baskerville/libre-baskerville-latin-1.woff2
Normal file
BIN
public/fonts/libre-baskerville/libre-baskerville-latin-1.woff2
Normal file
Binary file not shown.
Binary file not shown.
BIN
public/fonts/lora/lora-latin-1.woff2
Normal file
BIN
public/fonts/lora/lora-latin-1.woff2
Normal file
Binary file not shown.
BIN
public/fonts/lora/lora-latin-ext-0.woff2
Normal file
BIN
public/fonts/lora/lora-latin-ext-0.woff2
Normal file
Binary file not shown.
BIN
public/fonts/merriweather/merriweather-latin-1.woff2
Normal file
BIN
public/fonts/merriweather/merriweather-latin-1.woff2
Normal file
Binary file not shown.
BIN
public/fonts/merriweather/merriweather-latin-ext-0.woff2
Normal file
BIN
public/fonts/merriweather/merriweather-latin-ext-0.woff2
Normal file
Binary file not shown.
BIN
public/fonts/montserrat/montserrat-latin-1.woff2
Normal file
BIN
public/fonts/montserrat/montserrat-latin-1.woff2
Normal file
Binary file not shown.
BIN
public/fonts/montserrat/montserrat-latin-ext-0.woff2
Normal file
BIN
public/fonts/montserrat/montserrat-latin-ext-0.woff2
Normal file
Binary file not shown.
BIN
public/fonts/nunito/nunito-latin-1.woff2
Normal file
BIN
public/fonts/nunito/nunito-latin-1.woff2
Normal file
Binary file not shown.
BIN
public/fonts/nunito/nunito-latin-ext-0.woff2
Normal file
BIN
public/fonts/nunito/nunito-latin-ext-0.woff2
Normal file
Binary file not shown.
BIN
public/fonts/open-sans/open-sans-latin-1.woff2
Normal file
BIN
public/fonts/open-sans/open-sans-latin-1.woff2
Normal file
Binary file not shown.
BIN
public/fonts/open-sans/open-sans-latin-ext-0.woff2
Normal file
BIN
public/fonts/open-sans/open-sans-latin-ext-0.woff2
Normal file
Binary file not shown.
BIN
public/fonts/playfair-display/playfair-display-latin-1.woff2
Normal file
BIN
public/fonts/playfair-display/playfair-display-latin-1.woff2
Normal file
Binary file not shown.
BIN
public/fonts/playfair-display/playfair-display-latin-ext-0.woff2
Normal file
BIN
public/fonts/playfair-display/playfair-display-latin-ext-0.woff2
Normal file
Binary file not shown.
BIN
public/fonts/poppins/poppins-latin-1.woff2
Normal file
BIN
public/fonts/poppins/poppins-latin-1.woff2
Normal file
Binary file not shown.
BIN
public/fonts/poppins/poppins-latin-3.woff2
Normal file
BIN
public/fonts/poppins/poppins-latin-3.woff2
Normal file
Binary file not shown.
BIN
public/fonts/poppins/poppins-latin-5.woff2
Normal file
BIN
public/fonts/poppins/poppins-latin-5.woff2
Normal file
Binary file not shown.
BIN
public/fonts/poppins/poppins-latin-7.woff2
Normal file
BIN
public/fonts/poppins/poppins-latin-7.woff2
Normal file
Binary file not shown.
BIN
public/fonts/poppins/poppins-latin-ext-0.woff2
Normal file
BIN
public/fonts/poppins/poppins-latin-ext-0.woff2
Normal file
Binary file not shown.
BIN
public/fonts/poppins/poppins-latin-ext-2.woff2
Normal file
BIN
public/fonts/poppins/poppins-latin-ext-2.woff2
Normal file
Binary file not shown.
BIN
public/fonts/poppins/poppins-latin-ext-4.woff2
Normal file
BIN
public/fonts/poppins/poppins-latin-ext-4.woff2
Normal file
Binary file not shown.
BIN
public/fonts/poppins/poppins-latin-ext-6.woff2
Normal file
BIN
public/fonts/poppins/poppins-latin-ext-6.woff2
Normal file
Binary file not shown.
BIN
public/fonts/roboto/roboto-latin-1.woff2
Normal file
BIN
public/fonts/roboto/roboto-latin-1.woff2
Normal file
Binary file not shown.
BIN
public/fonts/roboto/roboto-latin-ext-0.woff2
Normal file
BIN
public/fonts/roboto/roboto-latin-ext-0.woff2
Normal file
Binary file not shown.
BIN
public/fonts/source-sans-3/source-sans-3-latin-1.woff2
Normal file
BIN
public/fonts/source-sans-3/source-sans-3-latin-1.woff2
Normal file
Binary file not shown.
BIN
public/fonts/source-sans-3/source-sans-3-latin-ext-0.woff2
Normal file
BIN
public/fonts/source-sans-3/source-sans-3-latin-ext-0.woff2
Normal file
Binary file not shown.
BIN
public/fonts/work-sans/work-sans-latin-1.woff2
Normal file
BIN
public/fonts/work-sans/work-sans-latin-1.woff2
Normal file
Binary file not shown.
BIN
public/fonts/work-sans/work-sans-latin-ext-0.woff2
Normal file
BIN
public/fonts/work-sans/work-sans-latin-ext-0.woff2
Normal file
Binary file not shown.
30
scripts/fonts-holen.py
Normal file
30
scripts/fonts-holen.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import re, json, urllib.request, urllib.error, pathlib
|
||||
UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0 Safari/537.36"
|
||||
FAMS = ['Playfair Display','Lora','Merriweather','Libre Baskerville','DM Serif Display','Inter','Roboto','Open Sans','Poppins','Montserrat','Nunito','Work Sans','Source Sans 3']
|
||||
out_dir = pathlib.Path('public/fonts'); out_dir.mkdir(parents=True, exist_ok=True)
|
||||
manifest = {}
|
||||
def get(url):
|
||||
return urllib.request.urlopen(urllib.request.Request(url, headers={'User-Agent': UA})).read()
|
||||
for fam in FAMS:
|
||||
css = None
|
||||
for w in ['400;500;600;700', '400;700', '400']:
|
||||
try:
|
||||
css = get(f"https://fonts.googleapis.com/css2?family={fam.replace(' ','+')}:wght@{w}&display=swap").decode(); break
|
||||
except urllib.error.HTTPError: pass
|
||||
slug = fam.lower().replace(' ', '-'); d = out_dir / slug; d.mkdir(exist_ok=True)
|
||||
faces = []; seen = {}
|
||||
for subset, body in re.findall(r'/\* ([\w-]+) \*/\s*@font-face \{(.*?)\}', css, re.S):
|
||||
if subset not in ('latin', 'latin-ext'): continue
|
||||
weight = re.search(r'font-weight: (\d+)', body).group(1)
|
||||
url = re.search(r'url\((.*?)\)', body).group(1)
|
||||
rng = re.search(r'unicode-range: (.*?);', body).group(1)
|
||||
if url not in seen:
|
||||
fn = f"{slug}-{subset}-{len(seen)}.woff2"; (d / fn).write_bytes(get(url)); seen[url] = fn
|
||||
faces.append({'weight': int(weight), 'subset': subset, 'file': f"/fonts/{slug}/{seen[url]}", 'unicodeRange': rng})
|
||||
# gleiche Datei fuer mehrere Gewichte (variable Schrift) -> eine Regel mit Gewichtsbereich
|
||||
merged = {}
|
||||
for f in faces:
|
||||
k = (f['file'], f['subset']); merged.setdefault(k, dict(f, weights=[]))['weights'].append(f['weight'])
|
||||
manifest[fam] = [{'file': v['file'], 'weight': f"{min(v['weights'])} {max(v['weights'])}" if len(v['weights']) > 1 else str(v['weights'][0]), 'unicodeRange': v['unicodeRange']} for v in merged.values()]
|
||||
print(fam, len(manifest[fam]), 'Regeln', len(seen), 'Dateien')
|
||||
json.dump(manifest, open('src/lib/font-faces.json', 'w', encoding='utf8'), indent=2)
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
import Nav from '../components/Nav.astro';
|
||||
import Footer from '../components/Footer.astro';
|
||||
import '../styles/global.css';
|
||||
import { site, theme, themeCss, googleFontsHref } from '../lib/content';
|
||||
import { site, theme, themeCss, fontFacesCss } from '../lib/content';
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
|
|
@ -10,7 +10,6 @@ interface Props {
|
|||
}
|
||||
|
||||
const { title, description = site.meta.description } = Astro.props;
|
||||
const fontsHref = googleFontsHref(theme);
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
|
|
@ -22,13 +21,7 @@ const fontsHref = googleFontsHref(theme);
|
|||
<meta name="description" content={description} />
|
||||
<title>{title} · Larpaso</title>
|
||||
|
||||
{fontsHref && (
|
||||
<>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link href={fontsHref} rel="stylesheet" />
|
||||
</>
|
||||
)}
|
||||
<style set:html={fontFacesCss(theme)} />
|
||||
<style set:html={themeCss(theme)} />
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import siteData from '../../content/site.json';
|
||||
import themeData from '../../content/theme.json';
|
||||
import { fontFamilyCss, googleFontsHref as buildGoogleFontsHref, inlineFontFacesCss } from './fonts';
|
||||
import { fontFamilyCss, localFontFacesCss, inlineFontFacesCss } from './fonts';
|
||||
import { sanitizeRich, collectUsedFonts } from './rich-sanitize';
|
||||
|
||||
export const site = siteData;
|
||||
|
|
@ -52,8 +52,8 @@ function collectAllStrings(value: unknown, out: string[]): void {
|
|||
}
|
||||
|
||||
/** Every font used anywhere via the rich-text editor's per-selection font
|
||||
* picker, on top of the theme's heading/body fonts - so a Google Fonts
|
||||
* request is only made for fonts actually in use. */
|
||||
* picker, on top of the theme's heading/body fonts - so only the fonts
|
||||
* actually in use get @font-face rules. */
|
||||
function usedInlineFonts(): string[] {
|
||||
const strings: string[] = [];
|
||||
collectAllStrings(site, strings);
|
||||
|
|
@ -80,8 +80,8 @@ export function themeCss(t: typeof theme): string {
|
|||
return lines.join('\n');
|
||||
}
|
||||
|
||||
export function googleFontsHref(t: typeof theme): string | null {
|
||||
return buildGoogleFontsHref([t.fonts.heading, t.fonts.body, ...usedInlineFonts()]);
|
||||
export function fontFacesCss(t: typeof theme): string {
|
||||
return localFontFacesCss([t.fonts.heading, t.fonts.body, ...usedInlineFonts()]);
|
||||
}
|
||||
|
||||
/** Replaces a literal `{email}` token with a mailto link, for legal-page
|
||||
|
|
|
|||
188
src/lib/font-faces.json
Normal file
188
src/lib/font-faces.json
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
{
|
||||
"Playfair Display": [
|
||||
{
|
||||
"file": "/fonts/playfair-display/playfair-display-latin-ext-0.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/playfair-display/playfair-display-latin-1.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
],
|
||||
"Lora": [
|
||||
{
|
||||
"file": "/fonts/lora/lora-latin-ext-0.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/lora/lora-latin-1.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
],
|
||||
"Merriweather": [
|
||||
{
|
||||
"file": "/fonts/merriweather/merriweather-latin-ext-0.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/merriweather/merriweather-latin-1.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
],
|
||||
"Libre Baskerville": [
|
||||
{
|
||||
"file": "/fonts/libre-baskerville/libre-baskerville-latin-ext-0.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/libre-baskerville/libre-baskerville-latin-1.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
],
|
||||
"DM Serif Display": [
|
||||
{
|
||||
"file": "/fonts/dm-serif-display/dm-serif-display-latin-ext-0.woff2",
|
||||
"weight": "400",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/dm-serif-display/dm-serif-display-latin-1.woff2",
|
||||
"weight": "400",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
],
|
||||
"Inter": [
|
||||
{
|
||||
"file": "/fonts/inter/inter-latin-ext-0.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/inter/inter-latin-1.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
],
|
||||
"Roboto": [
|
||||
{
|
||||
"file": "/fonts/roboto/roboto-latin-ext-0.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/roboto/roboto-latin-1.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
],
|
||||
"Open Sans": [
|
||||
{
|
||||
"file": "/fonts/open-sans/open-sans-latin-ext-0.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/open-sans/open-sans-latin-1.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
],
|
||||
"Poppins": [
|
||||
{
|
||||
"file": "/fonts/poppins/poppins-latin-ext-0.woff2",
|
||||
"weight": "400",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/poppins/poppins-latin-1.woff2",
|
||||
"weight": "400",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/poppins/poppins-latin-ext-2.woff2",
|
||||
"weight": "500",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/poppins/poppins-latin-3.woff2",
|
||||
"weight": "500",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/poppins/poppins-latin-ext-4.woff2",
|
||||
"weight": "600",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/poppins/poppins-latin-5.woff2",
|
||||
"weight": "600",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/poppins/poppins-latin-ext-6.woff2",
|
||||
"weight": "700",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/poppins/poppins-latin-7.woff2",
|
||||
"weight": "700",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
],
|
||||
"Montserrat": [
|
||||
{
|
||||
"file": "/fonts/montserrat/montserrat-latin-ext-0.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/montserrat/montserrat-latin-1.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
],
|
||||
"Nunito": [
|
||||
{
|
||||
"file": "/fonts/nunito/nunito-latin-ext-0.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/nunito/nunito-latin-1.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
],
|
||||
"Work Sans": [
|
||||
{
|
||||
"file": "/fonts/work-sans/work-sans-latin-ext-0.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/work-sans/work-sans-latin-1.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
],
|
||||
"Source Sans 3": [
|
||||
{
|
||||
"file": "/fonts/source-sans-3/source-sans-3-latin-ext-0.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"
|
||||
},
|
||||
{
|
||||
"file": "/fonts/source-sans-3/source-sans-3-latin-1.woff2",
|
||||
"weight": "400 700",
|
||||
"unicodeRange": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
import fontFaces from './font-faces.json';
|
||||
|
||||
export interface FontOption {
|
||||
name: string;
|
||||
category: 'serif' | 'sans';
|
||||
google: boolean; // false = system font, no Google Fonts request
|
||||
google: boolean; // true = a Google Font we host ourselves in public/fonts; false = system font
|
||||
fallback: string;
|
||||
}
|
||||
|
||||
|
|
@ -37,18 +39,23 @@ export function fontFamilyCss(name: string): string {
|
|||
return font.google ? `'${font.name}', ${font.fallback}` : font.fallback;
|
||||
}
|
||||
|
||||
/** Builds the Google Fonts CSS2 stylesheet URL for the given font names
|
||||
* (system fonts are skipped — nothing to fetch). Used for the theme's
|
||||
* heading/body fonts plus any fonts used inline via the rich-text editor. */
|
||||
export function googleFontsHref(fontNames: string[]): string | null {
|
||||
const families = fontNames
|
||||
/** Builds the @font-face rules for the given font names from the files in
|
||||
* public/fonts (see font-faces.json). The fonts are served from our own
|
||||
* server so a page view never contacts Google. System fonts are skipped. */
|
||||
export function localFontFacesCss(fontNames: string[]): string {
|
||||
const faces = fontFaces as Record<string, { file: string; weight: string; unicodeRange: string }[]>;
|
||||
return fontNames
|
||||
.map(findFont)
|
||||
.filter((f) => f.google)
|
||||
.filter((f, i, arr) => arr.findIndex((g) => g.name === f.name) === i)
|
||||
.map((f) => `family=${f.name.replace(/ /g, '+')}:wght@400;500;600;700`);
|
||||
|
||||
if (families.length === 0) return null;
|
||||
return `https://fonts.googleapis.com/css2?${families.join('&')}&display=swap`;
|
||||
.flatMap((f) =>
|
||||
(faces[f.name] || []).map(
|
||||
(face) =>
|
||||
`@font-face { font-family: '${f.name}'; font-style: normal; font-weight: ${face.weight}; ` +
|
||||
`font-display: swap; src: url('${face.file}') format('woff2'); unicode-range: ${face.unicodeRange}; }`,
|
||||
),
|
||||
)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
/** Builds `[data-font="Name"] { font-family: ...; }` rules for fonts used
|
||||
|
|
|
|||
|
|
@ -43,6 +43,6 @@ const introFallback =
|
|||
padding-top: var(--space-5);
|
||||
border-top: 1px solid var(--color-border);
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-flag);
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in a new issue