Compare commits
7 Commits
27380290e1
...
v0.1.12
| Author | SHA1 | Date | |
|---|---|---|---|
| 8d350bb092 | |||
| 4338028c60 | |||
| ab563a7b37 | |||
| 2cfc1a0047 | |||
| 98e8d971e8 | |||
| 87be06ecea | |||
| 28f6e1ae7c |
1
wp-content/themes/moonshine/.gitignore
vendored
1
wp-content/themes/moonshine/.gitignore
vendored
@@ -25,3 +25,4 @@ logs
|
|||||||
|
|
||||||
# Wrangler files
|
# Wrangler files
|
||||||
.wrangler
|
.wrangler
|
||||||
|
server/types/cloudflare.d.ts
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v0.1.12
|
||||||
|
|
||||||
|
[compare changes](https://gitea.websimple.com/wp-sites/wp-headless/compare/v0.1.11...v0.1.12)
|
||||||
|
|
||||||
|
### 🚀 Enhancements
|
||||||
|
|
||||||
|
- ConnexionButton (87be06e)
|
||||||
|
- ShowLabel (98e8d97)
|
||||||
|
- ParseAcfLink (2cfc1a0)
|
||||||
|
- ParseAcfMedia (ab563a7)
|
||||||
|
- Event context type for Cloudflare environment (4338028)
|
||||||
|
|
||||||
|
### 🩹 Fixes
|
||||||
|
|
||||||
|
- UApp in app.vue (28f6e1a)
|
||||||
|
|
||||||
## v0.1.11
|
## v0.1.11
|
||||||
|
|
||||||
[compare changes](https://gitea.websimple.com/wp-sites/wp-headless/compare/v0.1.10...v0.1.11)
|
[compare changes](https://gitea.websimple.com/wp-sites/wp-headless/compare/v0.1.10...v0.1.11)
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { fr } from "@nuxt/ui/locale";
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<UApp :locale="fr">
|
||||||
<NuxtRouteAnnouncer />
|
<NuxtRouteAnnouncer />
|
||||||
<NuxtLoadingIndicator />
|
<NuxtLoadingIndicator />
|
||||||
<NuxtLayout>
|
<NuxtLayout>
|
||||||
<NuxtPage />
|
<NuxtPage />
|
||||||
</NuxtLayout>
|
</NuxtLayout>
|
||||||
</div>
|
</UApp>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import type { ButtonProps } from "@nuxt/ui";
|
|||||||
|
|
||||||
type AcfLinkButtonProps = & Omit<ButtonProps, "to" | "target" | "href"> & {
|
type AcfLinkButtonProps = & Omit<ButtonProps, "to" | "target" | "href"> & {
|
||||||
link?: AcfLinkFragment;
|
link?: AcfLinkFragment;
|
||||||
|
showLabel?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const { link, ...buttonProps } = defineProps<AcfLinkButtonProps>();
|
const { link, showLabel, ...buttonProps } = defineProps<AcfLinkButtonProps>();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -18,6 +19,6 @@ const { link, ...buttonProps } = defineProps<AcfLinkButtonProps>();
|
|||||||
:external="link.target === '_blank'"
|
:external="link.target === '_blank'"
|
||||||
:rel="link.target === '_blank' ? 'noopener noreferrer' : undefined"
|
:rel="link.target === '_blank' ? 'noopener noreferrer' : undefined"
|
||||||
>
|
>
|
||||||
<slot>{{ link.title }}</slot>
|
<slot>{{ showLabel ? link.title : "" }}</slot>
|
||||||
</UButton>
|
</UButton>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
fragment AcfMedia on GroupAbstractMedia_Fields {
|
fragment AcfMedia on GroupAbstractMedia_Fields {
|
||||||
image {
|
image { node { ... AcfImage } }
|
||||||
node {
|
|
||||||
...AcfImage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
aspectRatio
|
aspectRatio
|
||||||
objectFit
|
objectFit
|
||||||
}
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
const { isLoggedIn } = useAuth();
|
|
||||||
const attrs = computed(() => {
|
|
||||||
return isLoggedIn.value
|
|
||||||
? {
|
|
||||||
label: "Déconnexion",
|
|
||||||
icon: "i-lucide-log-out",
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
label: "Connexion",
|
|
||||||
icon: "i-lucide-log-in",
|
|
||||||
};
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<AuthState>
|
|
||||||
<UButton to="/connexion" v-bind="attrs" color="neutral" />
|
|
||||||
</AuthState>
|
|
||||||
</template>
|
|
||||||
@@ -34,7 +34,7 @@ const classes = tvSectionHeroSplit({
|
|||||||
<section :class="classes.base()">
|
<section :class="classes.base()">
|
||||||
<div :class="classes.container()">
|
<div :class="classes.container()">
|
||||||
<UiProse :content="content" :class="classes.content()" />
|
<UiProse :content="content" :class="classes.content()" />
|
||||||
<AcfMedia :media="$props" :class="classes.media()" />
|
<AcfMedia :media="parseAcfMedia(props)" :class="classes.media()" />
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
const { connexionButton } = useAuthConnexion();
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="bg-inverted text-inverted py-1.5">
|
<div class="bg-inverted text-inverted py-1.5">
|
||||||
<div class="container flex flex-col sm:flex-row items-center gap-3">
|
<div class="container flex flex-col sm:flex-row items-center gap-3">
|
||||||
<SiteFooterCopyright class="sm:mr-auto" />
|
<SiteFooterCopyright class="sm:mr-auto" />
|
||||||
<AuthConnexionButton color="neutral" variant="link" />
|
<UButton v-bind="connexionButton" color="neutral" variant="link" />
|
||||||
<SiteFooterCredits />
|
<SiteFooterCredits />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,8 +8,5 @@
|
|||||||
<SvgSiteLogo class="h-12 w-auto" />
|
<SvgSiteLogo class="h-12 w-auto" />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
<template #right>
|
|
||||||
<AuthConnexionButton />
|
|
||||||
</template>
|
|
||||||
</UHeader>
|
</UHeader>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2,5 +2,6 @@ export function useAuth() {
|
|||||||
const { loggedIn: isLoggedIn, session } = useUserSession();
|
const { loggedIn: isLoggedIn, session } = useUserSession();
|
||||||
const hasRole = (role: string) => session.value?.user?.roles?.includes(role) || false;
|
const hasRole = (role: string) => session.value?.user?.roles?.includes(role) || false;
|
||||||
const isAdmin = computed(() => hasRole("administrator"));
|
const isAdmin = computed(() => hasRole("administrator"));
|
||||||
|
|
||||||
return { isLoggedIn, hasRole, isAdmin };
|
return { isLoggedIn, hasRole, isAdmin };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import type { FormSubmitEvent } from "@nuxt/ui";
|
|||||||
const isRedirecting = ref(false);
|
const isRedirecting = ref(false);
|
||||||
|
|
||||||
export function useAuthConnexion() {
|
export function useAuthConnexion() {
|
||||||
|
const { isLoggedIn } = useAuth();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const { fetch: refreshUserSession } = useUserSession();
|
const { fetch: refreshUserSession } = useUserSession();
|
||||||
const routeRedirect = useRoute().query.redirect as string || undefined;
|
const routeRedirect = useRoute().query.redirect as string || undefined;
|
||||||
@@ -67,5 +68,12 @@ export function useAuthConnexion() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { isRedirecting, login, logout };
|
// Dynamic connexion link
|
||||||
|
const connexionButton = computed(() => ({
|
||||||
|
label: isLoggedIn.value ? "Déconnexion" : "Connexion",
|
||||||
|
icon: isLoggedIn.value ? "i-lucide-log-out" : "i-lucide-log-in",
|
||||||
|
to: "/connexion",
|
||||||
|
}));
|
||||||
|
|
||||||
|
return { isRedirecting, login, logout, connexionButton };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { fr } from "@nuxt/ui/locale";
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UApp id="layout-default" :locale="fr">
|
<div id="layout-default">
|
||||||
<SiteHeader />
|
<SiteHeader />
|
||||||
<UMain>
|
<UMain>
|
||||||
<slot />
|
<slot />
|
||||||
</UMain>
|
</UMain>
|
||||||
<SiteFooter />
|
<SiteFooter />
|
||||||
</UApp>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
18
wp-content/themes/moonshine/app/utils/acf-link.ts
Normal file
18
wp-content/themes/moonshine/app/utils/acf-link.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import * as z from "zod";
|
||||||
|
import type { AcfLinkFragment } from "#graphql/operations";
|
||||||
|
|
||||||
|
const acfLinkSchema = z.object({
|
||||||
|
title: z.string(),
|
||||||
|
url: z.string(),
|
||||||
|
target: z.string().optional().default(""),
|
||||||
|
});
|
||||||
|
export type AcfLinkOutput = z.infer<typeof acfLinkSchema>;
|
||||||
|
|
||||||
|
export function parseAcfLink(data?: Partial<AcfLinkFragment>) {
|
||||||
|
try {
|
||||||
|
return acfLinkSchema.parse(data);
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
29
wp-content/themes/moonshine/app/utils/acf-media.ts
Normal file
29
wp-content/themes/moonshine/app/utils/acf-media.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import type { AcfMediaFragment } from "#graphql/operations";
|
||||||
|
import * as z from "zod";
|
||||||
|
|
||||||
|
export const acfImageSchema = z.object({
|
||||||
|
src: z.url(),
|
||||||
|
alt: z.string(),
|
||||||
|
mediaDetails: z.object({
|
||||||
|
width: z.number(),
|
||||||
|
height: z.number(),
|
||||||
|
}),
|
||||||
|
objectPosition: z.string().optional().default("center"),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const acfMediaSchema = z.object({
|
||||||
|
image: z.object({
|
||||||
|
node: acfImageSchema,
|
||||||
|
}),
|
||||||
|
aspectRatio: z.enum(["square", "video", "portrait", "auto"]).optional().default("auto"),
|
||||||
|
objectFit: z.enum(["cover", "contain"]).optional().default("cover"),
|
||||||
|
});
|
||||||
|
|
||||||
|
export function parseAcfMedia(data?: Partial<AcfMediaFragment>) {
|
||||||
|
try {
|
||||||
|
return acfMediaSchema.parse(data);
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,2 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
return ['project-id-version'=>'Moonshine','report-msgid-bugs-to'=>'','pot-creation-date'=>'2026-01-13 15:52+0000','po-revision-date'=>'2026-01-29 02:55+0000','last-translator'=>'','language-team'=>'Français du Canada','language'=>'fr_CA','plural-forms'=>'nplurals=2; plural=n > 1;','mime-version'=>'1.0','content-type'=>'text/plain; charset=UTF-8','content-transfer-encoding'=>'8bit','x-generator'=>'Loco https://localise.biz/','x-loco-version'=>'2.8.1; wp-6.9; php-8.3.27','x-domain'=>'moonshine','messages'=>['Heading styles'=>'Styles de titres','Headless WordPress theme based on Nuxt.'=>'Thème Wordpress headless basé sur Nuxt.','https://websimple.com/'=>'https://websimple.com/','Inline styles'=>'Styles de caractères','Link styles'=>'Styles de liens','Main menu'=>'Menu principal','Moonshine'=>'Moonshine','Paragraph styles'=>'Styles de paragraphes','Pascal Martineau '=>'Pascal Martineau ','Semi-bold'=>'Semi-gras']];
|
return array(
|
||||||
|
'project-id-version' => 'Moonshine',
|
||||||
|
'report-msgid-bugs-to' => '',
|
||||||
|
'pot-creation-date' => '2026-01-13 15:52+0000',
|
||||||
|
'po-revision-date' => '2026-01-29 02:55+0000',
|
||||||
|
'last-translator' => '',
|
||||||
|
'language-team' => 'Français du Canada',
|
||||||
|
'language' => 'fr_CA',
|
||||||
|
'plural-forms' => 'nplurals=2; plural=n > 1;',
|
||||||
|
'mime-version' => '1.0',
|
||||||
|
'content-type' => 'text/plain; charset=UTF-8',
|
||||||
|
'content-transfer-encoding' => '8bit',
|
||||||
|
'x-generator' => 'Loco https://localise.biz/',
|
||||||
|
'x-loco-version' => '2.8.1; wp-6.9; php-8.3.27',
|
||||||
|
'x-domain' => 'moonshine',
|
||||||
|
'messages' => array(
|
||||||
|
'Heading styles' => 'Styles de titres',
|
||||||
|
'Headless WordPress theme based on Nuxt.' => 'Thème Wordpress headless basé sur Nuxt.',
|
||||||
|
'https://websimple.com/' => 'https://websimple.com/',
|
||||||
|
'Inline styles' => 'Styles de caractères',
|
||||||
|
'Link styles' => 'Styles de liens',
|
||||||
|
'Main menu' => 'Menu principal',
|
||||||
|
'Moonshine' => 'Moonshine',
|
||||||
|
'Paragraph styles' => 'Styles de paragraphes',
|
||||||
|
'Pascal Martineau ' => 'Pascal Martineau ',
|
||||||
|
'Semi-bold' => 'Semi-gras',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|||||||
@@ -119,4 +119,5 @@ export default defineNuxtConfig({
|
|||||||
componentPrefix: "Svg",
|
componentPrefix: "Svg",
|
||||||
defaultImport: "component",
|
defaultImport: "component",
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,18 +1,26 @@
|
|||||||
{
|
{
|
||||||
"name": "@lewebsimple/moonshine",
|
"name": "@lewebsimple/moonshine",
|
||||||
"description": "Headless WordPress theme based on Nuxt.",
|
"description": "Headless WordPress theme based on Nuxt.",
|
||||||
"version": "0.1.11",
|
"version": "0.1.12",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nuxt build",
|
"build": "pnpm --sequential /build:.*/",
|
||||||
"editor-style": "pnpx @tailwindcss/cli -i ./app/assets/css/_main.css -o ./editor-style.css --minify",
|
"build:nuxt": "nuxt build",
|
||||||
"dev": "nuxt dev",
|
"dev": "nuxt dev",
|
||||||
"lint": "eslint --fix .",
|
"editor-style": "pnpx @tailwindcss/cli -i ./app/assets/css/_main.css -o ./editor-style.css --minify",
|
||||||
"postinstall": "nuxt prepare",
|
"lint": "eslint . --fix",
|
||||||
"preview": "WRANGLER_ENV=dev pnpm run build && wrangler dev --port 3000",
|
"postinstall": "pnpm --sequential /postinstall:.*/",
|
||||||
"release": "pnpm lint && changelogen --noAuthors --release --push",
|
"postinstall:wrangler-types": "pnpm wrangler types ./server/types/cloudflare.d.ts",
|
||||||
"typecheck": "nuxt typecheck"
|
"postinstall:nuxt": "nuxt prepare",
|
||||||
|
"preview": "pnpm --sequential /preview:.*/",
|
||||||
|
"preview:build": "pnpm run build",
|
||||||
|
"preview:wrangler-dev": "wrangler dev --port 3000",
|
||||||
|
"release": "pnpm --sequential /release:.*/",
|
||||||
|
"release:lint": "eslint .",
|
||||||
|
"release:typecheck": "nuxt typecheck",
|
||||||
|
"release:changelogen": "changelogen --noAuthors --release --push",
|
||||||
|
"wrangler": "wrangler --config .output/server/wrangler.json"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@iconify-json/cib": "^1.2.3",
|
"@iconify-json/cib": "^1.2.3",
|
||||||
|
|||||||
9
wp-content/themes/moonshine/server/types/h3.d.ts
vendored
Normal file
9
wp-content/themes/moonshine/server/types/h3.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import "h3";
|
||||||
|
|
||||||
|
declare module "h3" {
|
||||||
|
interface H3EventContext {
|
||||||
|
cloudflare: {
|
||||||
|
env: Cloudflare.Env;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user