mirror of
https://iceshrimp.dev/Crimekillz/jointrashposs.git
synced 2024-11-22 00:43:50 +01:00
(fix) CDNキャッシュ時の意図しないリダイレクトを軽減
This commit is contained in:
parent
7ff8485743
commit
5c5395dab6
@ -16,6 +16,8 @@ Website for Misskey, built with [Nuxt](https://nuxt.com/).
|
|||||||
|
|
||||||
内部リンク・外部リンクに関する処理を強化した[`<GNuxtLink>`](./components/g/NuxtLink.vue)を使用していますので、**リンクを追加する際は`<NuxtLink>`ではなく`<GNuxtLink>`を使用してください。**
|
内部リンク・外部リンクに関する処理を強化した[`<GNuxtLink>`](./components/g/NuxtLink.vue)を使用していますので、**リンクを追加する際は`<NuxtLink>`ではなく`<GNuxtLink>`を使用してください。**
|
||||||
|
|
||||||
|
また、Nuxtのルーティングストラテジに、ホスティング環境に適した設定を適用するため、動的リンクの作成に使用する`useLocalePath`をラップしたコンポーサブル関数`useGLocalePath`を使うようにしています。
|
||||||
|
|
||||||
### Misskey Webへのリンクについて
|
### Misskey Webへのリンクについて
|
||||||
|
|
||||||
GNuxtLinkおよび各種Docsで、アドレスに `x-mi-web://` から始め、続けてMisskeyの相対パスを入力すると、Misskey Webへのリンクに置き換えられます。
|
GNuxtLinkおよび各種Docsで、アドレスに `x-mi-web://` から始め、続けてMisskeyの相対パスを入力すると、Misskey Webへのリンクに置き換えられます。
|
||||||
|
@ -39,7 +39,7 @@ const realBasePath = computed<string>(() => {
|
|||||||
return route.path.replace(/^.*\/docs/, `/${locale.value}/docs`);
|
return route.path.replace(/^.*\/docs/, `/${locale.value}/docs`);
|
||||||
});
|
});
|
||||||
|
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
|
|
||||||
const query = queryContent(realBasePath.value);
|
const query = queryContent(realBasePath.value);
|
||||||
</script>
|
</script>
|
||||||
|
@ -7,7 +7,7 @@ import { isLocalPath, sanitizeInternalPath } from '@/assets/js/misc';
|
|||||||
const runtimeConfig = useRuntimeConfig();
|
const runtimeConfig = useRuntimeConfig();
|
||||||
const rootDomain = new $URL(runtimeConfig.public.baseUrl);
|
const rootDomain = new $URL(runtimeConfig.public.baseUrl);
|
||||||
const { resolve } = useRouter();
|
const { resolve } = useRouter();
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
href: {
|
href: {
|
||||||
|
@ -64,7 +64,7 @@
|
|||||||
import MiIcon from '@/assets/svg/misskey_mi_bi.svg';
|
import MiIcon from '@/assets/svg/misskey_mi_bi.svg';
|
||||||
import ExtIco from 'bi/box-arrow-up-right.svg';
|
import ExtIco from 'bi/box-arrow-up-right.svg';
|
||||||
|
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -122,7 +122,7 @@ watch(() => route.path,(to) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const switchLocalePath = useSwitchLocalePath();
|
const switchLocalePath = useSwitchLocalePath();
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
const spLocaleOption = ref<string>(currentLocale.value);
|
const spLocaleOption = ref<string>(currentLocale.value);
|
||||||
function changeLocale() {
|
function changeLocale() {
|
||||||
const path = switchLocalePath(spLocaleOption.value);
|
const path = switchLocalePath(spLocaleOption.value);
|
||||||
|
@ -25,7 +25,7 @@ const rawProps = defineProps<{
|
|||||||
target?: unknown;
|
target?: unknown;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
|
|
||||||
const needsToOpenExternally = ref(false);
|
const needsToOpenExternally = ref(false);
|
||||||
const realHref = computed(() => {
|
const realHref = computed(() => {
|
||||||
|
@ -8,5 +8,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
</script>
|
</script>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { vFadeIn } from 'assets/js/fadein';
|
import { vFadeIn } from 'assets/js/fadein';
|
||||||
|
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -39,7 +39,7 @@ import { isLocalPath } from '~/assets/js/misc';
|
|||||||
|
|
||||||
const { notice } = useAppConfig();
|
const { notice } = useAppConfig();
|
||||||
const { locale, fallbackLocale } = useI18n();
|
const { locale, fallbackLocale } = useI18n();
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
const showTagline = ref(false);
|
const showTagline = ref(false);
|
||||||
const colorMode = useColorMode();
|
const colorMode = useColorMode();
|
||||||
const mobileScreenShot = computed(() => (colorMode.preference === 'dark') ? '/img/hero/misskey-mobile-dark.png' : '/img/hero/misskey-mobile-light.png');
|
const mobileScreenShot = computed(() => (colorMode.preference === 'dark') ? '/img/hero/misskey-mobile-dark.png' : '/img/hero/misskey-mobile-light.png');
|
||||||
|
@ -15,7 +15,7 @@ const navData = props.d;
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const isShown = ref(false);
|
const isShown = ref(false);
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
|
|
||||||
watch(() => route.path, () => {
|
watch(() => route.path, () => {
|
||||||
if (navData.items.some((e) => isSamePath(route.path, localePath(e.to)))) {
|
if (navData.items.some((e) => isSamePath(route.path, localePath(e.to)))) {
|
||||||
|
17
composables/useGLocalPath.ts
Normal file
17
composables/useGLocalPath.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import {
|
||||||
|
getComposer,
|
||||||
|
useLocalePath as _useLocalePath,
|
||||||
|
} from 'vue-i18n-routing';
|
||||||
|
|
||||||
|
/** useLocalePathのラッパー関数。 */
|
||||||
|
export function useGLocalePath(
|
||||||
|
options?: NonNullable<Parameters<typeof _useLocalePath>[0]>
|
||||||
|
): ReturnType<typeof _useLocalePath> {
|
||||||
|
const { route, router, i18n, strategy } = options || {}
|
||||||
|
return _useLocalePath({
|
||||||
|
route: route || useRoute(),
|
||||||
|
router: router || useRouter(),
|
||||||
|
i18n: i18n || getComposer(useNuxtApp().$i18n),
|
||||||
|
strategy: strategy ?? 'prefix', // ←リンクではprefixつきにする
|
||||||
|
})
|
||||||
|
}
|
@ -34,7 +34,7 @@ const colorMode = useColorMode();
|
|||||||
const runtimeConfig = useRuntimeConfig();
|
const runtimeConfig = useRuntimeConfig();
|
||||||
|
|
||||||
const { locale, locales } = useI18n();
|
const { locale, locales } = useI18n();
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
const currentLocaleIso = computed(() => (locales.value as LocaleObject[]).find((e) => e?.code === locale.value)?.iso);
|
const currentLocaleIso = computed(() => (locales.value as LocaleObject[]).find((e) => e?.code === locale.value)?.iso);
|
||||||
|
|
||||||
const isNavOpen = ref<boolean>(false);
|
const isNavOpen = ref<boolean>(false);
|
||||||
|
@ -14,7 +14,7 @@ function clickNav() {
|
|||||||
const isNavOpen = ref<boolean>(false);
|
const isNavOpen = ref<boolean>(false);
|
||||||
const isAsideNavOpen = ref<boolean>(false);
|
const isAsideNavOpen = ref<boolean>(false);
|
||||||
|
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
|
|
||||||
useHead({
|
useHead({
|
||||||
htmlAttrs: {
|
htmlAttrs: {
|
||||||
|
@ -117,7 +117,8 @@ export default defineNuxtConfig({
|
|||||||
langDir: 'locales_dist',
|
langDir: 'locales_dist',
|
||||||
defaultLocale: 'ja',
|
defaultLocale: 'ja',
|
||||||
// ▼ Defaultルートは、nitroプラグインでオーバーライドする
|
// ▼ Defaultルートは、nitroプラグインでオーバーライドする
|
||||||
strategy: 'prefix',
|
// リンクはuseGLocalePath(ラッパー)を使う
|
||||||
|
strategy: 'prefix_and_default',
|
||||||
trailingSlash: true,
|
trailingSlash: true,
|
||||||
},
|
},
|
||||||
colorMode: {
|
colorMode: {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ const route = useRoute();
|
|||||||
|
|
||||||
// ▼他言語からやってきたときに正しいパスに戻す▼
|
// ▼他言語からやってきたときに正しいパスに戻す▼
|
||||||
const originalLocale = useState('miHub_blog_originalLocale', () => 'ja');
|
const originalLocale = useState('miHub_blog_originalLocale', () => 'ja');
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
const getRouteBaseName = useRouteBaseName();
|
const getRouteBaseName = useRouteBaseName();
|
||||||
let isTransformed = false;
|
let isTransformed = false;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ const localeState = useState('miHub_blog_originalLocale', () => locale.value);
|
|||||||
localeState.value = locale.value;
|
localeState.value = locale.value;
|
||||||
|
|
||||||
const { data } = await useAsyncData('blog', () => queryContent('blog').only(['_path', 'navTitle', 'title', 'date']).sort({ date: -1 }).find());
|
const { data } = await useAsyncData('blog', () => queryContent('blog').only(['_path', 'navTitle', 'title', 'date']).sort({ date: -1 }).find());
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
|
|
||||||
route.meta.title = t('_blog.title');
|
route.meta.title = t('_blog.title');
|
||||||
route.meta.description = t('_blog.description');
|
route.meta.description = t('_blog.description');
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
route.meta.title = t('_other.title');
|
route.meta.title = t('_other.title');
|
||||||
|
@ -51,7 +51,7 @@ import type { InstancesStatsObj } from '@/types/instances-info';
|
|||||||
import ArrowRightIco from "bi/arrow-right.svg";
|
import ArrowRightIco from "bi/arrow-right.svg";
|
||||||
|
|
||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const instancesStats = ref<InstancesStatsObj>();
|
const instancesStats = ref<InstancesStatsObj>();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -46,7 +46,7 @@ definePageMeta({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const localePath = useLocalePath();
|
const localePath = useGLocalePath();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
route.meta.title = t('_tools.title');
|
route.meta.title = t('_tools.title');
|
||||||
|
Loading…
Reference in New Issue
Block a user