Last active
March 1, 2025 08:02
-
-
Save RickCogley/e651580e616acf231fea18cb2d49ca95 to your computer and use it in GitHub Desktop.
Lume 3 Temporal Tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cms.collection({ | |
name: "posts", | |
label: "ブログポスト Blog posts", | |
description: "日本語と英語のブログポストを編集する<br>Edit blog posts in Japanese and English", | |
store: "src:posts/*.md", | |
documentName(data) { | |
return `${new Date().toISOString().slice(0,10).replace(/-/g,"")}-${data.title}-${data.lang}.md`; | |
}, | |
fields: [ | |
{ | |
name: "lang", | |
type: "select", | |
label: "言語 Language", | |
description: "コンテンツの言語を選択する<br>Select the language of the page content", | |
attributes: { | |
required: true, | |
}, | |
options: [ | |
{ | |
label: "日本語", | |
value: "ja" | |
}, | |
{ | |
label: "English", | |
value: "en" | |
}, | |
], | |
}, | |
{ | |
name: "id", | |
type: "text", | |
label: "固有ID Unique ID", | |
description: "A unique string (e.g. YYYYMMDDHHMM) that acts to group a set of translated content pages together. It should be the same for all translations of the same content. Use the autogenerated one, or enter your own.", | |
value: new Date().toISOString().slice(0,16).replace(/[^0-9]/g, ""), | |
attributes: { | |
required: true, | |
}, | |
}, | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /src/_data.ts | |
export const currentDateTime = Temporal.Now.zonedDateTimeISO(); | |
console.log(`Current temporal timezoned datetime: ${currentDateTime.toString()}`); | |
export const currentDateTimeInTokyo = Temporal.Now.zonedDateTimeISO('Asia/Tokyo'); | |
console.log(`Current temporal datetime in Tokyo: ${currentDateTimeInTokyo.toString()}`); | |
console.log(`Current temporal date in Tokyo: ${currentDateTimeInTokyo.toPlainDate()}`); | |
const formatter = new Intl.DateTimeFormat('ja-JP-u-ca-japanese', { | |
year: 'numeric', | |
month: 'numeric', | |
day: 'numeric', | |
timeZone: 'Asia/Tokyo' | |
}); | |
const formattedDate = formatter.format(currentDateTimeInTokyo.toPlainDate()); | |
console.log("Kanji? " + formattedDate); | |
export const currentJapanLocaleDateTimeInTokyo = currentDateTimeInTokyo.toLocaleString('ja-JP', { | |
year: 'numeric', | |
month: '2-digit', | |
day: '2-digit', | |
hour: '2-digit', | |
minute: '2-digit', | |
hourCycle: 'h23', | |
}); | |
console.log(currentJapanLocaleDateTimeInTokyo); | |
export const currentDateTimeYYYYMMDDHHMM = currentJapanLocaleDateTimeInTokyo.replace(/[^0-9]/g, '').slice(0, 12); | |
console.log(currentDateTimeYYYYMMDDHHMM); | |
const now = Temporal.Now.instant(); | |
const fmtArgs = [ | |
["ja-JP"], | |
{ | |
year: "numeric", | |
month: "long", | |
day: "numeric", | |
} | |
]; | |
console.log(new Intl.DateTimeFormat(...fmtArgs).format(now.epochMilliseconds)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"imports": { | |
"lume/": "https://cdn.jsdelivr.net/gh/lumeland/lume@3ca4e1ff0077bc5239d853e9efdc60889546ce30/", | |
"lume/cms/": "https://cdn.jsdelivr.net/gh/lumeland/[email protected]/" | |
}, | |
"tasks": { | |
"lume": "echo \"import 'lume/cli.ts'\" | deno run -A -", | |
"build": "deno task lume", | |
"serve": "deno task lume -s", | |
"update-deps": "deno run -A --quiet 'https://deno.land/x/[email protected]/cli.ts' update plugins.ts deno.json" | |
}, | |
"compilerOptions": { | |
"types": [ | |
"lume/types.ts" | |
] | |
}, | |
"lint": { | |
"exclude": [ | |
"./_site" | |
], | |
"rules": { | |
"tags": [ | |
"recommended" | |
] | |
} | |
}, | |
"fmt": { | |
"exclude": [ | |
"./_site" | |
] | |
}, | |
"unstable": ["temporal"], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment