fix: avoid loading analytics in localhost

This commit is contained in:
Felipe M 2024-03-18 18:16:30 +01:00
parent 453486761d
commit 672c34aa1a
Signed by: fmartingr
GPG key ID: CCFBC5637D4000A8
7 changed files with 38 additions and 30 deletions

View 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
View 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",
]
},
)

View file

@ -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

View file

@ -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',
]
}
)