fix: avoid loading analytics in localhost
This commit is contained in:
parent
453486761d
commit
672c34aa1a
7 changed files with 38 additions and 30 deletions
6
Makefile
6
Makefile
|
@ -4,7 +4,7 @@ BUILD_STATE_PATH ?= ${PWD}/.lektor
|
|||
SERVER_PORT ?= 8080
|
||||
|
||||
server:
|
||||
lektor server -f $(LEKTOR_FLAGS) -p $(SERVER_PORT)
|
||||
LEKTOR_DEV=1 lektor server -f $(LEKTOR_FLAGS) -p $(SERVER_PORT)
|
||||
|
||||
clean:
|
||||
rm -rf public
|
||||
|
@ -12,3 +12,7 @@ clean:
|
|||
|
||||
build: clean
|
||||
lektor build -f $(LEKTOR_FLAGS) --output-path $(BUILD_OUTPUT_PATH) --buildstate-path $(BUILD_STATE_PATH)
|
||||
|
||||
new_post:
|
||||
mkdir -p content/blog/$(shell date +%Y-%m-%d)-new-post
|
||||
echo "title: New post\n---\npub_date: $(shell date +%Y-%m-%d)\n---\nbody:\n\n" >> content/blog/$(shell date +%Y-%m-%d)-new-post/contents.lr
|
||||
|
|
17
packages/helpers/lektor_helpers.py
Normal file
17
packages/helpers/lektor_helpers.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
import os
|
||||
|
||||
from lektor.pluginsystem import Plugin
|
||||
|
||||
|
||||
class HelpersPlugin(Plugin):
|
||||
name = "helpers"
|
||||
description = "Helpers for my site"
|
||||
|
||||
def on_process_template_context(self, context, **extra):
|
||||
# Add the datetime package to the template context
|
||||
context["datetime"] = datetime
|
||||
|
||||
# Add a variable to the template context to check if the site is running in development mode
|
||||
context["is_dev"] = os.environ.get("LEKTOR_DEV") == "1"
|
15
packages/helpers/setup.py
Normal file
15
packages/helpers/setup.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name="lektor-helpers",
|
||||
version="0.1",
|
||||
author="Felipe Martin",
|
||||
author_email="me@fmartingr.com",
|
||||
license="MIT",
|
||||
py_modules=["lektor_helpers"],
|
||||
entry_points={
|
||||
"lektor.plugins": [
|
||||
"helpers = lektor_helpers:HelpersPlugin",
|
||||
]
|
||||
},
|
||||
)
|
|
@ -1,13 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
|
||||
|
||||
from lektor.pluginsystem import Plugin
|
||||
|
||||
|
||||
class TemplateDatetimePlugin(Plugin):
|
||||
name = u'template-datetime'
|
||||
description = u'Adds the datetime package to the template context'
|
||||
|
||||
def on_process_template_context(self, context, **extra):
|
||||
context['datetime'] = datetime
|
|
@ -1,15 +0,0 @@
|
|||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='lektor-template-datetime',
|
||||
version='0.1',
|
||||
author=u'Felipe Martin',
|
||||
author_email='me@fmartingr.com',
|
||||
license='MIT',
|
||||
py_modules=['lektor_template_datetime'],
|
||||
entry_points={
|
||||
'lektor.plugins': [
|
||||
'template-datetime = lektor_template_datetime:TemplateDatetimePlugin',
|
||||
]
|
||||
}
|
||||
)
|
|
@ -12,7 +12,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
|
||||
<meta http-equiv="cleartype" content="on">
|
||||
{% block analytics %}
|
||||
<script defer src="https://umami.fmartingr.dev/script.js" data-website-id="18da78a4-f6bd-4560-88fd-e28ca0b487fa"></script>
|
||||
{% if not is_dev %}<script defer src="https://umami.fmartingr.dev/script.js" data-website-id="18da78a4-f6bd-4560-88fd-e28ca0b487fa"></script>{% endif %}
|
||||
{% endblock %}
|
||||
{% block endhead %}{% endblock %}
|
||||
</head>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue