Compare commits
10 commits
23aeeb0e0b
...
296b036db1
| Author | SHA1 | Date | |
|---|---|---|---|
| 296b036db1 | |||
| 3ba5a6a043 | |||
| 9886c29feb | |||
| 92c7b2b1c1 | |||
| b5adc27c9d | |||
| 9758dbd561 | |||
| 404abaae6c | |||
| b67dd88cac | |||
| 9cfa14abf7 | |||
| 4ffc695b65 |
21 changed files with 207 additions and 55 deletions
|
|
@ -1,3 +1,24 @@
|
||||||
|
# navbar
|
||||||
|
[home]
|
||||||
|
en = "home"
|
||||||
|
es = "inicio"
|
||||||
|
|
||||||
|
[about]
|
||||||
|
en = "about"
|
||||||
|
es = "acerca de"
|
||||||
|
|
||||||
|
[blog]
|
||||||
|
en = "blog"
|
||||||
|
es = "blog"
|
||||||
|
|
||||||
|
[music]
|
||||||
|
en = "music"
|
||||||
|
es = "música"
|
||||||
|
|
||||||
|
[etc]
|
||||||
|
en = "etc"
|
||||||
|
es = "etc"
|
||||||
|
|
||||||
# 404
|
# 404
|
||||||
[404]
|
[404]
|
||||||
en = "404 not found"
|
en = "404 not found"
|
||||||
|
|
@ -11,11 +32,12 @@ es = "vuelve a casa <3"
|
||||||
en = "by yasuhira"
|
en = "by yasuhira"
|
||||||
es = "por yasuhira"
|
es = "por yasuhira"
|
||||||
|
|
||||||
# homepage
|
# under construction
|
||||||
[home]
|
[under-construction]
|
||||||
en = "home"
|
en = "this page is under construction!!"
|
||||||
es = "inicio"
|
es = "aún estoy haciendo esta página!!"
|
||||||
|
|
||||||
|
# homepage
|
||||||
[please-visit]
|
[please-visit]
|
||||||
en = "please visit..."
|
en = "please visit..."
|
||||||
es = "visita también..."
|
es = "visita también..."
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,23 @@
|
||||||
[en]
|
[home]
|
||||||
[en.home]
|
|
||||||
name = "home"
|
name = "home"
|
||||||
url = "/en/"
|
url = "/"
|
||||||
|
|
||||||
[en.about]
|
[about]
|
||||||
name = "about"
|
name = "about"
|
||||||
url = "/en/about/"
|
url = "/about/"
|
||||||
|
|
||||||
[en.blog]
|
[blog]
|
||||||
name = "blog"
|
name = "blog"
|
||||||
url = "/en/blog/"
|
url = "/blog/"
|
||||||
|
|
||||||
[en.reviews]
|
[reviews]
|
||||||
name = "reviews"
|
name = "reviews"
|
||||||
url = "/en/reviews/"
|
url = "/reviews/"
|
||||||
|
|
||||||
[en.music]
|
[music]
|
||||||
name = "music"
|
name = "music"
|
||||||
url = "https://smalrainbow.bandcamp.com/"
|
url = "https://smalrainbow.bandcamp.com/"
|
||||||
new_tab = true
|
new_tab = true
|
||||||
|
|
||||||
[en.etc]
|
[etc]
|
||||||
name = "etc"
|
|
||||||
|
|
||||||
[es]
|
|
||||||
[es.home]
|
|
||||||
name = "inicio"
|
|
||||||
url = "/es/"
|
|
||||||
|
|
||||||
[es.about]
|
|
||||||
name = "acerca de"
|
|
||||||
url = "/es/acerca-de/"
|
|
||||||
|
|
||||||
[es.blog]
|
|
||||||
name = "blog"
|
|
||||||
url = "/es/blog/"
|
|
||||||
|
|
||||||
[es.reviews]
|
|
||||||
name = "reviews"
|
|
||||||
url = "/es/reviews/"
|
|
||||||
|
|
||||||
[es.music]
|
|
||||||
name = "música"
|
|
||||||
url = "https://smalrainbow.bandcamp.com/"
|
|
||||||
new_tab = true
|
|
||||||
|
|
||||||
[es.etc]
|
|
||||||
name = "etc"
|
name = "etc"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<div class="footer-flex">
|
<div class="footer-flex">
|
||||||
<div class="footer-left">
|
<div class="footer-left">
|
||||||
{% if show_lang_in_footer %}
|
{% if not dont_show_lang_in_footer %}
|
||||||
{% include "lang-available.njk" %}
|
{% include "lang-available.njk" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<nav class="navbar-wrapper">
|
<nav class="navbar-wrapper">
|
||||||
<div class="navbar-content">
|
<div class="navbar-content">
|
||||||
<ul>
|
<ul>
|
||||||
{% for item in navbar[page.lang] | values %}
|
{% for item in navbar | values %}
|
||||||
<li id="{{ item.name }}">{% if item.url %}<a href="{{ item.url }}" {% if item.new_tab %}target="_blank"{% endif %}>{{ item.name }}</a>{% else %}<p>{{ item.name }}</p>{% endif %}</li>
|
<li id="{{ item.name }}">{% if item.url %}<a href="{{ item.url | locale_url_resolve }}" {% if item.new_tab %}target="_blank"{% endif %}>{{ item.name | i18n }}</a>{% else %}<p>{{ item.name | i18n }}</p>{% endif %}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<li id="nav-hover" aria-hidden="true"></li>
|
<li id="nav-hover" aria-hidden="true"></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
---
|
|
||||||
show_lang_in_footer: true
|
|
||||||
---
|
|
||||||
{% extends "_layouts/base.njk" %}
|
{% extends "_layouts/base.njk" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ lastfm: true
|
||||||
flight:
|
flight:
|
||||||
img: "/img/Witch-on-broom.gif"
|
img: "/img/Witch-on-broom.gif"
|
||||||
url: "https://www.youtube.com/embed/w1dXpAJ1qfA"
|
url: "https://www.youtube.com/embed/w1dXpAJ1qfA"
|
||||||
|
dont_show_lang_in_footer: true
|
||||||
---
|
---
|
||||||
{% extends "_layouts/base.njk" %}
|
{% extends "_layouts/base.njk" %}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
---
|
---
|
||||||
# TODO: finish post page
|
# TODO: finish post page
|
||||||
tags: post
|
tags: post
|
||||||
show_lang_in_footer: true
|
|
||||||
---
|
---
|
||||||
{% extends "_layouts/base.njk" %}
|
{% extends "_layouts/base.njk" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
|
||||||
9
_layouts/under_construction.njk
Normal file
9
_layouts/under_construction.njk
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{% extends "_layouts/base.njk" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div id="under-construction">
|
||||||
|
<h2>{{ "under-construction" | i18n }}</h2>
|
||||||
|
<img src="/img/fatalframe.gif" alt={{ "under-construction" | i18n }}>
|
||||||
|
{{ content | safe }}
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
||||||
|
|
@ -89,6 +89,23 @@ body {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// under construction
|
||||||
|
#under-construction {
|
||||||
|
width: 100%;
|
||||||
|
h2 {
|
||||||
|
font-size: 1.4em;
|
||||||
|
text-align: center;
|
||||||
|
text-decoration: none;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
img {
|
||||||
|
display: block;
|
||||||
|
width: fit-content;
|
||||||
|
margin: 8px auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.header-wrapper {
|
.header-wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
const { I18nPlugin } = require("@11ty/eleventy");
|
const {
|
||||||
|
I18nPlugin
|
||||||
|
} = require("@11ty/eleventy");
|
||||||
const i18n = require("eleventy-plugin-i18n");
|
const i18n = require("eleventy-plugin-i18n");
|
||||||
const eleventySass = require("eleventy-sass");
|
const eleventySass = require("eleventy-sass");
|
||||||
const toml = require("@iarna/toml");
|
const toml = require("@iarna/toml");
|
||||||
|
|
@ -6,9 +8,9 @@ const toml = require("@iarna/toml");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
module.exports = function(eleventyConfig) {
|
module.exports = function (eleventyConfig) {
|
||||||
eleventyConfig.setLayoutsDirectory("_layouts");
|
eleventyConfig.setLayoutsDirectory("_layouts");
|
||||||
|
|
||||||
eleventyConfig.addPassthroughCopy("img");
|
eleventyConfig.addPassthroughCopy("img");
|
||||||
eleventyConfig.addPassthroughCopy("css/fonts");
|
eleventyConfig.addPassthroughCopy("css/fonts");
|
||||||
eleventyConfig.addPassthroughCopy("js");
|
eleventyConfig.addPassthroughCopy("js");
|
||||||
|
|
@ -16,9 +18,15 @@ module.exports = function(eleventyConfig) {
|
||||||
eleventyConfig.addPassthroughCopy("robots.txt");
|
eleventyConfig.addPassthroughCopy("robots.txt");
|
||||||
eleventyConfig.addPassthroughCopy("roms");
|
eleventyConfig.addPassthroughCopy("roms");
|
||||||
|
|
||||||
|
const defaultLanguage = "en";
|
||||||
|
// expose as global site data for templates
|
||||||
|
eleventyConfig.addGlobalData("site", {
|
||||||
|
defaultLocale: defaultLanguage
|
||||||
|
});
|
||||||
|
|
||||||
eleventyConfig.addNunjucksFilter("values", obj => Object.values(obj));
|
eleventyConfig.addNunjucksFilter("values", obj => Object.values(obj));
|
||||||
|
|
||||||
eleventyConfig.addFilter("i18n_filter", function(collection, limit = null) {
|
eleventyConfig.addFilter("i18n_filter", function (collection, limit = null) {
|
||||||
const lang = this.page.lang; // access page.lang from context
|
const lang = this.page.lang; // access page.lang from context
|
||||||
let filtered = collection.filter(item => item.data.lang === lang);
|
let filtered = collection.filter(item => item.data.lang === lang);
|
||||||
if (limit !== null) {
|
if (limit !== null) {
|
||||||
|
|
@ -29,8 +37,8 @@ module.exports = function(eleventyConfig) {
|
||||||
|
|
||||||
eleventyConfig.addPlugin(eleventySass);
|
eleventyConfig.addPlugin(eleventySass);
|
||||||
eleventyConfig.addPlugin(I18nPlugin, {
|
eleventyConfig.addPlugin(I18nPlugin, {
|
||||||
defaultLanguage: "en",
|
defaultLanguage: defaultLanguage,
|
||||||
errorMode: "allow-fallback" // /en/ -> /
|
errorMode: "allow-fallback", // /en/ -> /
|
||||||
});
|
});
|
||||||
eleventyConfig.addDataExtension("toml", (contents) => toml.parse(contents));
|
eleventyConfig.addDataExtension("toml", (contents) => toml.parse(contents));
|
||||||
|
|
||||||
|
|
@ -40,6 +48,94 @@ module.exports = function(eleventyConfig) {
|
||||||
);
|
);
|
||||||
const translations = toml.parse(translationsToml);
|
const translations = toml.parse(translationsToml);
|
||||||
|
|
||||||
|
const LOCALE_URL_DEBUG = process.env.LOCALE_URL_DEBUG === "1" || process.env.LOCALE_URL_DEBUG === "true";
|
||||||
|
|
||||||
|
eleventyConfig.addNunjucksFilter("locale_url_resolve", function (targetUrl, desiredLocale) {
|
||||||
|
const ctx = (this && this.ctx) ? this.ctx : {};
|
||||||
|
const collections = (ctx.collections) ? ctx.collections : {};
|
||||||
|
const all = collections.all || [];
|
||||||
|
|
||||||
|
if (!targetUrl || typeof targetUrl !== "string") return targetUrl;
|
||||||
|
if (!targetUrl.startsWith("/")) return targetUrl; // external or relative link -> leave as is
|
||||||
|
|
||||||
|
// determine locale to resolve to
|
||||||
|
const pageLang = desiredLocale || (ctx.page && ctx.page.lang) || ctx.locale || defaultLanguage;
|
||||||
|
|
||||||
|
if (LOCALE_URL_DEBUG) {
|
||||||
|
console.warn(`[locale_url_resolve] resolving targetUrl="${targetUrl}" desiredLocale="${desiredLocale}" pageLang="${pageLang}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if requested locale is default, return the raw url (your default publishes to root)
|
||||||
|
if (pageLang === defaultLanguage) {
|
||||||
|
if (LOCALE_URL_DEBUG) console.warn(`[locale_url_resolve] requested locale is default (${defaultLanguage}) — returning raw URL "${targetUrl}"`);
|
||||||
|
return targetUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// normalize targetUrl to ensure trailing slash for comparison
|
||||||
|
const normUrl = targetUrl.endsWith("/") ? targetUrl : (targetUrl + "/");
|
||||||
|
|
||||||
|
// try to find the canonical (default language) page corresponding to targetUrl
|
||||||
|
let canonical = all.find(p => {
|
||||||
|
return (p.url === normUrl || p.url === targetUrl) && p.data && p.data.lang === defaultLanguage;
|
||||||
|
});
|
||||||
|
|
||||||
|
// if not found, try to find any page with that url (maybe targetUrl already localized)
|
||||||
|
if (!canonical) {
|
||||||
|
canonical = all.find(p => (p.url === normUrl || p.url === targetUrl));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LOCALE_URL_DEBUG) {
|
||||||
|
if (canonical) {
|
||||||
|
const cs = (canonical.page && canonical.page.filePathStem) ? canonical.page.filePathStem : "(no stem)";
|
||||||
|
const clang = (canonical.data && canonical.data.lang) ? canonical.data.lang : "(no lang)";
|
||||||
|
console.warn(`[locale_url_resolve] canonical found: url="${canonical.url}" filePathStem="${cs}" lang="${clang}"`);
|
||||||
|
} else {
|
||||||
|
console.warn(`[locale_url_resolve] canonical NOT found for targetUrl="${targetUrl}". Will fallback to prefixed URL.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if cannot find canonical page, fall back to a prefixed URL (best effort)
|
||||||
|
if (!canonical) {
|
||||||
|
const fallback = (`/${pageLang}${targetUrl}`).replace(/\/{2,}/g, "/");
|
||||||
|
if (LOCALE_URL_DEBUG) console.warn(`[locale_url_resolve] fallback -> "${fallback}"`);
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine canonical filePathStem (the source input path without extension)
|
||||||
|
const canonicalLang = canonical.data && canonical.data.lang ? canonical.data.lang : defaultLanguage;
|
||||||
|
const canonicalStem = (canonical.page && canonical.page.filePathStem) ? canonical.page.filePathStem : "";
|
||||||
|
|
||||||
|
// remove the canonical lang prefix from the stem to create a "key" we can match across locales.
|
||||||
|
// e.g. "/en/about" -> "/about", "/es/about" -> "/about"
|
||||||
|
const key = canonicalStem.replace(new RegExp(`^/${canonicalLang}`), "").replace(/^\/+/, "");
|
||||||
|
|
||||||
|
if (LOCALE_URL_DEBUG) {
|
||||||
|
console.warn(`[locale_url_resolve] canonicalLang="${canonicalLang}" canonicalStem="${canonicalStem}" key="${key}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// find the localized page whose filePathStem ends with that key and whose lang matches pageLang.
|
||||||
|
const localized = all.find(p => {
|
||||||
|
const pLang = p.data && p.data.lang;
|
||||||
|
const pStem = (p.page && p.page.filePathStem) ? p.page.filePathStem : "";
|
||||||
|
// be defensive: ensure pLang exists
|
||||||
|
if (!pLang) return false;
|
||||||
|
return pLang === pageLang && pStem.endsWith(key);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (localized && localized.url) {
|
||||||
|
if (LOCALE_URL_DEBUG) {
|
||||||
|
const ls = (localized.page && localized.page.filePathStem) ? localized.page.filePathStem : "(no stem)";
|
||||||
|
console.warn(`[locale_url_resolve] localized found: url="${localized.url}" filePathStem="${ls}" lang="${localized.data.lang}"`);
|
||||||
|
}
|
||||||
|
return localized.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
// no localized page found — fall back to prefixed path
|
||||||
|
const fallback2 = (`/${pageLang}${targetUrl}`).replace(/\/{2,}/g, "/");
|
||||||
|
if (LOCALE_URL_DEBUG) console.warn(`[locale_url_resolve] localized NOT found for key="${key}" — fallback -> "${fallback2}"`);
|
||||||
|
return fallback2;
|
||||||
|
});
|
||||||
|
|
||||||
eleventyConfig.addPlugin(i18n, {
|
eleventyConfig.addPlugin(i18n, {
|
||||||
translations,
|
translations,
|
||||||
fallbackLocales: {
|
fallbackLocales: {
|
||||||
|
|
|
||||||
4
en/about.md
Normal file
4
en/about.md
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: about me
|
||||||
|
layout: under_construction
|
||||||
|
---
|
||||||
4
en/blog/index.md
Normal file
4
en/blog/index.md
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: blog
|
||||||
|
layout: under_construction
|
||||||
|
---
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: umihara kawase
|
||||||
|
layout: under_construction
|
||||||
|
---
|
||||||
|
|
@ -10,3 +10,5 @@ welcome to my site!! as with every website this is a heavy work in progress. how
|
||||||
- all pages marked as "under construction"
|
- all pages marked as "under construction"
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
you can browser however you like in the meanwhile.
|
||||||
|
|
|
||||||
4
en/reviews/index.md
Normal file
4
en/reviews/index.md
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: reviews
|
||||||
|
layout: under_construction
|
||||||
|
---
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
title: 404 not found
|
title: 404 no encontrado
|
||||||
---
|
---
|
||||||
{% extends "_layouts/base.njk" %}
|
{% extends "_layouts/base.njk" %}
|
||||||
|
|
||||||
|
|
|
||||||
5
es/about.md
Normal file
5
es/about.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: sobre mí
|
||||||
|
layout: under_construction
|
||||||
|
slug_override: acerca-de
|
||||||
|
---
|
||||||
4
es/blog/index.md
Normal file
4
es/blog/index.md
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: blog
|
||||||
|
layout: under_construction
|
||||||
|
---
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: umihara kawase
|
||||||
|
layout: under_construction
|
||||||
|
---
|
||||||
|
|
@ -3,10 +3,12 @@ layout: home
|
||||||
title: home
|
title: home
|
||||||
---
|
---
|
||||||
#### holaaa
|
#### holaaa
|
||||||
bienvenid@ a mi sitio!! aun no lo termino pero revisa lo que tenga hecho <3 pienso terminar primero:
|
bienvenid@ a mi sitio!! aún no lo termino <3 pienso terminar primero:
|
||||||
- un feed rss (atom)
|
- un feed rss (atom)
|
||||||
- mejor soporte para celulares
|
- mejor soporte para celulares
|
||||||
- ~~página 404~~
|
- ~~página 404~~
|
||||||
- terminar todas las páginas marcadas como "en construcción"
|
- terminar todas las páginas marcadas como "en construcción"
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
por mientras siéntete en casa y revisa lo que quieras.
|
||||||
|
|
|
||||||
4
es/reviews/index.md
Normal file
4
es/reviews/index.md
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: reviews
|
||||||
|
layout: under_construction
|
||||||
|
---
|
||||||
Loading…
Add table
Reference in a new issue