Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vuepress: 1.8.0 → 1.9.8 (minor) #19

Closed
wants to merge 1 commit into from

Conversation

depfu[bot]
Copy link
Contributor

@depfu depfu bot commented Jan 7, 2023

Here is everything you need to know about this update. Please take a good look at what changed and the test results before merging this pull request.

What changed?

✳️ vuepress (1.8.0 → 1.9.8) · Repo · Changelog

Release Notes

1.9.8 (from changelog)

Bug Fixes

1.9.7 (from changelog)

Bug Fixes

1.9.6 (from changelog)

Bug Fixes

Features

1.9.5 (from changelog)

Features

1.9.4 (from changelog)

Bug Fixes

Features

1.9.3 (from changelog)

Bug Fixes

1.9.2

TS Support for VuePress Plugin and Theme.

Motivation

We've announced VuePress 1.9 that takes full TypeScript Support for Config File, while VuePress 1.9.2 ships with TS Support for VuePress Plugin and Theme:

Quick Start

In order to make the plugin developer not dependent on VuePress for development, we provide a completely independent type package @vuepress/types:

npm i @vuepress/types -D

@vuepress/types exports four functions:

  • defineConfig
  • defineConfig4CustomTheme
  • defineTheme
  • definePlugin

Note that using @vuepress/types is equivalent to using vuepress/config.

Plugin Type

If you already have some VuePress plugins written in JS, you can leverage your IDE's intellisense with jsdoc type hints:

/**
 * @type {import('@vuepress/types').Plugin}
 */
module.exports = {
  ready() {
    // ...
  }
};

Alternatively, you can use the defineConfig helper which should provide intellisense without the need for jsdoc annotations:

import { definePlugin } from "@vuepress/types";

export default definePlugin({
// ...
});

Plugin Options Type

Type of plugin options also supports passing in through generic type:

import { definePlugin } from "@vuepress/types";

interface Options {
name: string;
}

export default definePlugin<Options>((options, ctx) => {
return {
ready() {
return ctx.base + options.name;
}
};
});

Theme Type

Similar to plugin, the only difference is the type you use, and the define function:

 /**
- * @type {import('@vuepress/types').Plugin}
+ * @type {import('@vuepress/types').Theme}
  */
-import { definePlugin } from "@vuepress/types";
+import { defineTheme } from "@vuepress/types";

-export default definePlugin({
+export default defineTheme({
// ...
});

Theme Config Type

Type of theme config also supports passing in through generic type:

import { defineTheme } from "@vuepress/types";

interface ThemeConfig {
lang: string;
}

export default defineTheme<ThemeConfig>((themeConfig, ctx) => {
return {
ready() {
return ctx.base + themeConfig.lang;
}
};
});

Notes

It is worth noting that, unlike the site configuration, i.e. .vuepress/config.js, if you use TypeScript to write theme or plugin, you still need to compile it into JavaScript before publishing it to NPM.

1.9.1 (from changelog)

Bug Fixes

  • types: support plain string usage for known third-party plugins (dd6e3ef) @chenhaoli

1.9.0

Overview

VuePress 1.9 introduced full TypeScript Support for Config File:

1 9-overview

Features

Support .vuepress/config.ts

Previously, VuePress only supported these configurations

  • .vuepress/config.js
  • .vuepress/config.yml
  • .vuepress/config.toml

From now on, .vuepress/config.ts get officially supported.

defineConfig helper for config intellisense

A helper function exposed at vuepress/config, which helps you to have type prompt:

import { defineConfig } from "vuepress/config";

export default defineConfig({
title: "VuePress",
description: "Vue-powered Static Site Generator"
// ...
});

Type Inferences for Theme

By default, defineConfig helper leverages type of Default Theme Config as themeConfig, i.e, type hints for all Default Theme Config is available for now.

import { defineConfig } from "vuepress/config";

export default defineConfig({
themeConfig: {
repo: "vuejs/vuepress",
editLinks: true,
docsDir: "packages/docs/docs"
// Type is DefaultThemeConfig
}
});

If you use a custom theme, you can use the defineConfig4CustomTheme helper with ability to pass generic type for your theme:

import { defineConfig4CustomTheme } from "vuepress/config";

interface MyThemeConfig {
hello: string;
}

export default defineConfig4CustomTheme<MyThemeConfig>({
themeConfig: {
// Type is MyThemeConfig
hello: "vuepress"
}
});

Type Inferences for Official Plugins

From now, you’ll be able to enjoy the type prompt of the official plugins:

1 9-official-plugin-tuple-usage

Options of the official plugins certainly have type prompts, Both Tuple Style, Object Style, and Plugin Shorthand support type inference:

  • Tuple Style:
import { defineConfig } from "vuepress/config";

export default defineConfig({
plugins: [
[
"@vuepress/pwa",
{
serviceWorker: true
}
]
]
});

1 9-official-plugin-options

  • Object Style:
import { defineConfig } from "vuepress/config";

export default defineConfig({
plugins: {
"@vuepress/pwa": {
serviceWorker: true
}
}
});

The illustration snapshot is omitted here, you can try it yourself.

ISO Language Code

Type inference supports ISO Language Code

1 9-lang

Context API

VuePress’s configuration can also be a function, while its first parameter is the current app context:

import { defineConfig } from "vuepress/config";

export default defineConfig(ctx => ({
// do not execute babel compilation under development
evergreen: ctx.isProd
}));

Limitations

It is worth noting that third-party plugins do not support Plugin Shorthand if you’re using Tuple Style to write your config, this is because from the perspective of the type system, the unknown shortcut is equivalent to string, which results in the failure of type inference.

By default, only officially maintained and plugins under VuePress Community support shortcut, feel free to submit pull request to add your plugin at this file.

Credits

1.8.3

Bug Fixes

Features

  • plugin-last-updated: inject lastUpdatedTimestamp to $page (#1778) (2345902)

1.8.2

Bug Fixes

  • $default-theme: sidebar groups are not opened when directly navigating to these pages (fix #2564) (#2565) (3ab9fca)
  • $markdown: support path without file extension when importing code snippets (#2677) (bb4ae4e)

1.8.1

1.8.1 (2021-02-11)

Bug Fixes

  • $core: component CodeGroup loads correctly on clientfix #2711 (#2794) (51277f8)
  • $theme-default: override algoliaOptions correctly (ba89f39)
  • deps: [security] bump ini from 1.3.5 to 1.3.8 (aeb8dce)
  • deps: bump autoprefixer from 9.6.1 to 9.8.6 (775b3de)
  • deps: bump vue from 2.6.10 to 2.6.12 (830dd4c)

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.


Depfu Status

Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with @depfu rebase.

All Depfu comment commands
@​depfu rebase
Rebases against your default branch and redoes this update
@​depfu recreate
Recreates this PR, overwriting any edits that you've made to it
@​depfu merge
Merges this PR once your tests are passing and conflicts are resolved
@​depfu close
Closes this PR and deletes the branch
@​depfu reopen
Restores the branch and reopens this PR (if it's closed)
@​depfu pause
Ignores all future updates for this dependency and closes this PR
@​depfu pause [minor|major]
Ignores all future minor/major updates for this dependency and closes this PR
@​depfu resume
Future versions of this dependency will create PRs again (leaves this PR as is)

@depfu depfu bot added the depfu label Jan 7, 2023
@depfu
Copy link
Contributor Author

depfu bot commented Feb 26, 2023

Closed in favor of #21.

1 similar comment
@depfu
Copy link
Contributor Author

depfu bot commented Feb 26, 2023

Closed in favor of #21.

@depfu depfu bot closed this Feb 26, 2023
@depfu depfu bot deleted the depfu/update/npm/vuepress-1.9.8 branch February 26, 2023 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants