valaxy 1.0.0-beta.2 → 1.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import type { Post } from 'valaxy'
3
- import { onContentUpdated, runContentUpdated, useCodePen, useCollapseCode, useCopyCode, useMediumZoom, wrapTable } from 'valaxy'
3
+ import { onContentUpdated, runContentUpdated, setIframeAspectRatios, useCodePen, useCollapseCode, useCopyCode, useMediumZoom, wrapTable } from 'valaxy'
4
4
  import { onMounted, onUpdated, ref } from 'vue'
5
5
  import { useI18n } from 'vue-i18n'
6
6
  import { useCodeGroups } from '../composables/codeGroups'
@@ -13,9 +13,14 @@ const props = defineProps<{
13
13
 
14
14
  const { t } = useI18n()
15
15
 
16
- const contentRef = ref()
16
+ const contentRef = ref<HTMLElement>()
17
17
  onContentUpdated(() => {
18
- wrapTable(contentRef.value)
18
+ const content = contentRef.value
19
+ if (!content)
20
+ return
21
+
22
+ wrapTable(content)
23
+ setIframeAspectRatios(content)
19
24
  })
20
25
 
21
26
  onMounted(() => {
@@ -41,8 +46,8 @@ useVanillaLazyLoad()
41
46
  </script>
42
47
 
43
48
  <template>
44
- <article v-if="$slots.default" :class="frontmatter.markdownClass || 'markdown-body'">
45
- <slot ref="contentRef" @vue:updated="runContentUpdated" />
49
+ <article v-if="$slots.default" ref="contentRef" :class="frontmatter.markdownClass || 'markdown-body'">
50
+ <slot @vue:updated="runContentUpdated" />
46
51
 
47
52
  <div v-if="frontmatter.url" text="center">
48
53
  <a
@@ -75,4 +80,12 @@ useVanillaLazyLoad()
75
80
  .medium-zoom-image--opened {
76
81
  z-index: 999;
77
82
  }
83
+
84
+ // Keep dimensioned embeds proportional when their width is constrained by the
85
+ // article. :where() deliberately leaves explicit author styles in control.
86
+ :where(iframe[data-va-responsive-iframe]) {
87
+ max-width: 100%;
88
+ height: auto;
89
+ aspect-ratio: var(--va-iframe-aspect-ratio);
90
+ }
78
91
  </style>
@@ -0,0 +1,34 @@
1
+ const RESPONSIVE_IFRAME_ATTRIBUTE = 'data-va-responsive-iframe'
2
+ const IFRAME_ASPECT_RATIO_PROPERTY = '--va-iframe-aspect-ratio'
3
+
4
+ function parsePositiveDimension(value: string | null) {
5
+ if (value === null)
6
+ return
7
+
8
+ const dimension = Number(value)
9
+ if (Number.isFinite(dimension) && dimension > 0)
10
+ return dimension
11
+ }
12
+
13
+ /**
14
+ * Make dimensioned iframes responsive without assuming a fixed video ratio.
15
+ * The generated custom property is consumed by the low-specificity markdown
16
+ * styles, so an author's explicit height or aspect-ratio still takes priority.
17
+ */
18
+ export function setIframeAspectRatios(container: ParentNode = document) {
19
+ container.querySelectorAll<HTMLIFrameElement>('iframe').forEach((iframe) => {
20
+ const width = parsePositiveDimension(iframe.getAttribute('width'))
21
+ const height = parsePositiveDimension(iframe.getAttribute('height'))
22
+
23
+ if (width && height) {
24
+ iframe.setAttribute(RESPONSIVE_IFRAME_ATTRIBUTE, '')
25
+ iframe.style.setProperty(IFRAME_ASPECT_RATIO_PROPERTY, `${width} / ${height}`)
26
+ return
27
+ }
28
+
29
+ if (iframe.hasAttribute(RESPONSIVE_IFRAME_ATTRIBUTE)) {
30
+ iframe.removeAttribute(RESPONSIVE_IFRAME_ATTRIBUTE)
31
+ iframe.style.removeProperty(IFRAME_ASPECT_RATIO_PROPERTY)
32
+ }
33
+ })
34
+ }
@@ -3,6 +3,7 @@ export * from './cdn'
3
3
  export * from './code'
4
4
  export * from './content'
5
5
  export * from './helper'
6
+ export * from './iframe'
6
7
  export * from './router'
7
8
  export * from './time'
8
9
  export * from './types'
@@ -1,7 +1,7 @@
1
1
  import 'node:process';
2
2
  import 'yargs';
3
3
  import 'yargs/helpers';
4
- export { c as cli, I as registerDevCommand, W as run, Y as startValaxyDev } from '../../shared/valaxy._QBHi6cy.mjs';
4
+ export { c as cli, I as registerDevCommand, W as run, Y as startValaxyDev } from '../../shared/valaxy.gIHfh4CV.mjs';
5
5
  import 'node:os';
6
6
  import 'node:path';
7
7
  import 'consola';
@@ -1,4 +1,4 @@
1
- export { A as ALL_ROUTE, E as EXCERPT_SEPARATOR, G as GLOBAL_STATE, P as PATHNAME_PROTOCOL_RE, V as ViteValaxyPlugins, b as build, c as cli, a as createServer, d as createValaxyPlugin, e as customElements, f as defaultSiteConfig, g as defaultValaxyConfig, h as defaultViteConfig, i as defineAddon, j as defineConfig, k as defineSiteConfig, l as defineTheme, m as defineValaxyAddon, n as defineValaxyConfig, o as defineValaxyTheme, p as encryptContent, q as generateClientRedirects, r as getGitTimestamp, s as getIndexHtml, t as getServerInfoText, u as isExternal, v as isInstalledGlobally, w as isKatexEnabled, x as isKatexPluginNeeded, y as isMathJaxEnabled, z as isPath, B as loadConfigFromFile, C as mergeValaxyConfig, D as mergeViteConfigs, F as postProcessForSSG, H as processValaxyOptions, I as registerDevCommand, J as resolveAddonsConfig, K as resolveImportPath, L as resolveImportUrl, M as resolveOptions, N as resolveSiteConfig, O as resolveSiteConfigFromRoot, Q as resolveThemeConfigFromRoot, R as resolveThemeValaxyConfig, S as resolveUserThemeConfig, T as resolveValaxyConfig, U as resolveValaxyConfigFromRoot, W as run, X as ssgBuild, Y as startValaxyDev, Z as toAtFS, _ as transformObject, $ as version } from '../shared/valaxy._QBHi6cy.mjs';
1
+ export { A as ALL_ROUTE, E as EXCERPT_SEPARATOR, G as GLOBAL_STATE, P as PATHNAME_PROTOCOL_RE, V as ViteValaxyPlugins, b as build, c as cli, a as createServer, d as createValaxyPlugin, e as customElements, f as defaultSiteConfig, g as defaultValaxyConfig, h as defaultViteConfig, i as defineAddon, j as defineConfig, k as defineSiteConfig, l as defineTheme, m as defineValaxyAddon, n as defineValaxyConfig, o as defineValaxyTheme, p as encryptContent, q as generateClientRedirects, r as getGitTimestamp, s as getIndexHtml, t as getServerInfoText, u as isExternal, v as isInstalledGlobally, w as isKatexEnabled, x as isKatexPluginNeeded, y as isMathJaxEnabled, z as isPath, B as loadConfigFromFile, C as mergeValaxyConfig, D as mergeViteConfigs, F as postProcessForSSG, H as processValaxyOptions, I as registerDevCommand, J as resolveAddonsConfig, K as resolveImportPath, L as resolveImportUrl, M as resolveOptions, N as resolveSiteConfig, O as resolveSiteConfigFromRoot, Q as resolveThemeConfigFromRoot, R as resolveThemeValaxyConfig, S as resolveUserThemeConfig, T as resolveValaxyConfig, U as resolveValaxyConfigFromRoot, W as run, X as ssgBuild, Y as startValaxyDev, Z as toAtFS, _ as transformObject, $ as version } from '../shared/valaxy.gIHfh4CV.mjs';
2
2
  import 'node:path';
3
3
  import 'consola';
4
4
  import 'fs-extra';
@@ -2727,7 +2727,7 @@ async function setupMarkdownPlugins(md, options, base = "/") {
2727
2727
  return md;
2728
2728
  }
2729
2729
 
2730
- const version = "1.0.0-beta.2";
2730
+ const version = "1.0.0-rc.2";
2731
2731
 
2732
2732
  const GLOBAL_STATE = {
2733
2733
  valaxyApp: void 0,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "valaxy",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.2",
4
+ "version": "1.0.0-rc.2",
5
5
  "description": "📄 Vite & Vue powered static blog generator.",
6
6
  "author": {
7
7
  "email": "me@yunyoujun.cn",
@@ -139,8 +139,8 @@
139
139
  "vitepress-plugin-group-icons": "^1.7.5",
140
140
  "vue-i18n": "^11.4.6",
141
141
  "yargs": "^18.0.0",
142
- "@valaxyjs/devtools": "1.0.0-beta.2",
143
- "@valaxyjs/utils": "1.0.0-beta.2"
142
+ "@valaxyjs/devtools": "1.0.0-rc.2",
143
+ "@valaxyjs/utils": "1.0.0-rc.2"
144
144
  },
145
145
  "devDependencies": {
146
146
  "@mdit-vue/plugin-component": "^3.0.2",