diff --git a/.gitignore b/.gitignore
index 8021e11..7b54534 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,5 +21,6 @@ docs/_build
.env
.astro/
+package-lock.json
node_modules/
npm-debug.log*
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/docs/conf.py b/docs/conf.py
index 8b13789..293c020 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1 +1,21 @@
+project = "Shibuya"
+copyright = "2023, Hsiaoming Yang"
+author = "Hsiaoming Yang"
+
+html_theme = "shibuya"
+html_baseurl = "https://shibuya.lepture.com"
+html_logo = "https://typlog.com/assets/logo-black.svg"
+
+html_theme_options = {
+ "logo_target": "/",
+ "light_logo": "https://typlog.com/assets/logo-black.svg",
+ "dark_logo": "https://typlog.com/assets/logo-white.svg",
+
+ "head_links": [
+ {
+ "name": "Documentation",
+ "url": "/"
+ },
+ ]
+}
diff --git a/docs/index.rst b/docs/index.rst
index f213ba1..41425bd 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,2 +1,4 @@
Shibuya for Sphinx
==================
+
+haha
diff --git a/package.json b/package.json
index 6e02fe2..9196a91 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,12 @@
{
"name": "shibuya",
"version": "1.0.0",
+ "scripts": {
+ "build": "esbuild static/index.js --bundle --outfile=shibuya/theme/shibuya/static/shibuya.js",
+ "dev": "npm run build -- --watch"
+ },
"devDependencies": {
+ "esbuild": "^0.17.6",
"tailwindcss": "^3.2.4"
}
}
diff --git a/pyproject.toml b/pyproject.toml
index 773b9f5..d1abfee 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,8 +1,8 @@
[project]
-name = "sphinx-shibuya"
+name = "shibuya"
description = "A clean, responsive, and customisable Sphinx documentation theme with light/dark mode."
dynamic = ["version"]
-readme = "README.rst"
+readme = "README.md"
requires-python = ">=3.7"
dependencies = [
@@ -34,3 +34,10 @@ classifiers = [
[project.urls]
GitHub = "https://github.com/lepture/shibuya"
+
+[build-system]
+requires = ["setuptools"]
+build-backend = "setuptools.build_meta"
+
+[tool.setuptools.dynamic]
+version = {attr = "shibuya.__version__"}
diff --git a/serve.py b/serve.py
index 196ec5a..7e987a9 100644
--- a/serve.py
+++ b/serve.py
@@ -1,6 +1,6 @@
from livereload import Server, shell
app = Server()
-app.watch("sphinx_shibuya/src", shell("make build-docs"))
+app.watch("src", shell("make build-docs"))
app.watch("docs", shell("make build-docs"))
app.serve(root="build/_html")
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..7d35f73
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,4 @@
+from setuptools import setup
+
+# for pip install -e
+setup()
diff --git a/shibuya/__init__.py b/shibuya/__init__.py
deleted file mode 100644
index 56baa92..0000000
--- a/shibuya/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from pathlib import Path
-
-__version__ = '1.0.0'
-
-THEME_PATH = (Path(__file__).parent / "theme" / "shibuya").resolve()
-
-
-def setup(app):
- """Entry point for sphinx theming."""
- app.add_html_theme("shibuya", str(THEME_PATH))
- return {
- "parallel_read_safe": True,
- "parallel_write_safe": True,
- "version": __version__,
- }
diff --git a/shibuya/theme/shibuya/layout.html b/shibuya/theme/shibuya/layout.html
deleted file mode 100644
index 4400978..0000000
--- a/shibuya/theme/shibuya/layout.html
+++ /dev/null
@@ -1,21 +0,0 @@
-{%- set lang_attr = 'en' if language == None else (language | replace('_', '-')) -%}
-
-
-
-
-
-
- {%- block htmltitle -%}
- {{ title|striptags|e }}{{ titlesuffix }}
- {% endblock %}
- {%- if favicon -%}
-
- {%- endif %}
- {%- if theme_canonical_url -%}
-
- {%- endif -%}
-
-
- {% block body %}{% endblock %}
-
-
diff --git a/shibuya/theme/shibuya/theme.conf b/shibuya/theme/shibuya/theme.conf
deleted file mode 100644
index b359ebf..0000000
--- a/shibuya/theme/shibuya/theme.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-
-project = "shibuya"
-copyright = "2023, Hsiaoming Yang"
-author = "Hsiaoming Yang"
diff --git a/src/shibuya/__init__.py b/src/shibuya/__init__.py
new file mode 100644
index 0000000..7fd84d1
--- /dev/null
+++ b/src/shibuya/__init__.py
@@ -0,0 +1,31 @@
+from typing import Dict, Any
+from pathlib import Path
+from sphinx.builders.html import StandaloneHTMLBuilder
+from .context import (
+ BASE_CSS_VARIABLES,
+ LIGHT_CSS_VARIABLES,
+ DARK_CSS_VARIABLES,
+ css_to_dict,
+)
+
+__version__ = '1.0.0'
+
+THEME_PATH = (Path(__file__).parent / "theme" / "shibuya").resolve()
+
+
+def _html_page_context(app, pagename: str, templatename: str, context: Dict[str, Any], doctree):
+ assert isinstance(app.builder, StandaloneHTMLBuilder)
+ context["shibuya_base_css_variables"] = css_to_dict(BASE_CSS_VARIABLES)
+ context["shibuya_light_css_variables"] = css_to_dict(LIGHT_CSS_VARIABLES)
+ context["shibuya_dark_css_variables"] = css_to_dict(DARK_CSS_VARIABLES)
+
+
+def setup(app):
+ """Entry point for sphinx theming."""
+ app.add_html_theme("shibuya", str(THEME_PATH))
+ app.connect("html-page-context", _html_page_context)
+ return {
+ "parallel_read_safe": True,
+ "parallel_write_safe": True,
+ "version": __version__,
+ }
diff --git a/src/shibuya/context.py b/src/shibuya/context.py
new file mode 100644
index 0000000..e9dcb21
--- /dev/null
+++ b/src/shibuya/context.py
@@ -0,0 +1,32 @@
+BASE_CSS_VARIABLES = """
+--sy-f-sys: -apple-system, BlinkMacSystemFont, Segoe UI, Oxygen, Ubuntu, Droid Sans, Helvetica Neue;
+--sy-f-latin: Inter, var(--sy-f-sys);
+--sy-f-cjk: PingFang SC, Hiragino Sans GB, Droid Sans Fallback, Microsoft YaHei;
+--sy-f-heading: var(--sy-f-latin), var(--sy-f-cjk), sans-serif;
+--sy-f-text: var(--sy-f-latin), var(--sy-f-cjk), sans-serif;
+--sy-c-text: rgba(var(--sy-rc-text), 0.86);
+--sy-c-divider: var(--sy-rc-text, 0.1);
+"""
+
+LIGHT_CSS_VARIABLES = """
+--sy-rc-bg: 255, 255, 255;
+--sy-rc-text: 0, 0, 0;
+--sy-c-bg: #fff;
+--sy-c-bg-weak: #f9f9f9;
+"""
+
+DARK_CSS_VARIABLES = """
+--sy-rc-bg: 18, 18, 18;
+--sy-rc-text: 255, 255, 255;
+--sy-c-bg: rgba(var(--sy-rc-bg), 0.86);
+"""
+
+def css_to_dict(text: str):
+ css_vars = {}
+ for line in text.strip().splitlines():
+ if not line:
+ continue
+ line = line.rstrip(";")
+ key, value = line.split(':')
+ css_vars[key.strip()] = value.strip()
+ return css_vars
diff --git a/src/shibuya/theme/shibuya/components/css_variables.html b/src/shibuya/theme/shibuya/components/css_variables.html
new file mode 100644
index 0000000..d86c26c
--- /dev/null
+++ b/src/shibuya/theme/shibuya/components/css_variables.html
@@ -0,0 +1,33 @@
+{%- macro declare_css_vars(sys_vars, user_vars) -%}
+ {%- if user_vars -%}
+ {%- for name in sys_vars -%}
+ {%- if name in user_vars -%}
+ {{ name }}:{{user_vars[name]}};
+ {%- else -%}
+ {{ name }}:{{sys_vars[name]}};
+ {%- endif -%}
+ {%- endfor -%}
+ {%- else -%}
+ {%- for name in sys_vars -%}
+ {{ name }}:{{sys_vars[name]}};
+ {%- endfor -%}
+ {%- endif -%}
+{%- endmacro -%}
+
+
diff --git a/src/shibuya/theme/shibuya/components/site_footer.html b/src/shibuya/theme/shibuya/components/site_footer.html
new file mode 100644
index 0000000..e69de29
diff --git a/src/shibuya/theme/shibuya/components/site_header.html b/src/shibuya/theme/shibuya/components/site_header.html
new file mode 100644
index 0000000..e69de29
diff --git a/src/shibuya/theme/shibuya/components/theme_select.html b/src/shibuya/theme/shibuya/components/theme_select.html
new file mode 100644
index 0000000..e69de29
diff --git a/src/shibuya/theme/shibuya/layout.html b/src/shibuya/theme/shibuya/layout.html
new file mode 100644
index 0000000..fb95153
--- /dev/null
+++ b/src/shibuya/theme/shibuya/layout.html
@@ -0,0 +1,70 @@
+
+
+
+
+
+ {%- block htmltitle -%}
+ {{ title|striptags|e }}{{ titlesuffix }}
+ {% endblock %}
+ {%- block linktags %}
+ {%- if hasdoc('about') -%}
+
+ {%- endif -%}
+ {%- if hasdoc('genindex') -%}
+
+ {%- endif -%}
+ {%- if hasdoc('search') -%}
+
+ {%- endif -%}
+ {%- if hasdoc('copyright') -%}
+
+ {%- endif -%}
+ {%- if next -%}
+
+ {%- endif -%}
+ {%- if prev -%}
+
+ {%- endif -%}
+ {%- if pageurl %}
+
+ {%- endif %}
+ {%- endblock linktags %}
+ {%- if favicon_url -%}
+
+ {%- endif %}
+
+ {%- block styles -%}
+ {%- for css in css_files -%}
+ {% if css|attr("filename") -%}
+ {{ css_tag(css) }}
+ {%- else -%}
+
+ {%- endif %}
+ {% endfor -%}
+ {% include "components/css_variables.html" with context %}
+ {% block theme_styles %}{% endblock %}
+ {%- endblock -%}
+ {% block extrahead %}{% endblock %}
+ {% include "partials/meta_head.html" %}
+
+
+
+ {%- block header -%}
+ {% include "components/site_header.html" with context %}
+ {%- endblock -%}
+
+ {% block body %}{% endblock %}
+
+ {%- block footer -%}
+ {% include "components/site_footer.html" with context %}
+ {%- endblock -%}
+
+
+ {%- block scripts -%}
+ {%- for js in script_files %}
+ {{ js_tag(js) }}
+ {%- endfor %}
+ {% block theme_scripts %}{% endblock %}
+ {%- endblock %}
+
+
diff --git a/shibuya/theme/shibuya/page.html b/src/shibuya/theme/shibuya/page.html
similarity index 100%
rename from shibuya/theme/shibuya/page.html
rename to src/shibuya/theme/shibuya/page.html
diff --git a/src/shibuya/theme/shibuya/partials/comment.html b/src/shibuya/theme/shibuya/partials/comment.html
new file mode 100644
index 0000000..e69de29
diff --git a/src/shibuya/theme/shibuya/partials/meta_head.html b/src/shibuya/theme/shibuya/partials/meta_head.html
new file mode 100644
index 0000000..e69de29
diff --git a/src/shibuya/theme/shibuya/static/shibuya.js b/src/shibuya/theme/shibuya/static/shibuya.js
new file mode 100644
index 0000000..8afef30
--- /dev/null
+++ b/src/shibuya/theme/shibuya/static/shibuya.js
@@ -0,0 +1,2 @@
+(() => {
+})();
diff --git a/src/shibuya/theme/shibuya/theme.conf b/src/shibuya/theme/shibuya/theme.conf
new file mode 100644
index 0000000..e7f1770
--- /dev/null
+++ b/src/shibuya/theme/shibuya/theme.conf
@@ -0,0 +1,13 @@
+[theme]
+inherit = basic
+
+[options]
+logo_target =
+light_logo =
+dark_logo =
+
+base_css_variables =
+light_css_variables =
+dark_css_variables =
+
+head_links =
diff --git a/static/index.js b/static/index.js
new file mode 100644
index 0000000..e69de29